Welcome Guest, Not a member yet? Register   Sign In
email library does not convert to html format anymore
#1

(This post was last modified: 09-13-2022, 02:48 AM by blazin_eu.)

Hello, so as the title says since about 1 month ago the email library i use in CI3 to send emails from a contact form does not format my emails in html format and outputs some wird code. 

View:
PHP Code:
<form action="" method="post" class="contact-form">
                <input required="required" value="<?php echo !empty($postData['name']) ? $postData['name'] : ''; ?>"
                      type="text" name="name" class="contact-form-input first-input" placeholder="Nume">
                <input required value="<?php echo !empty($postData['email']) ? $postData['email'] : ''; ?>" type="email"
                      pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" name="email" class="contact-form-input"
                      placeholder="Email">
                <input required value="<?php echo !empty($postData['phone']) ? $postData['phone'] : ''; ?>" type="tel"
                      pattern="[+]?[0-9]{10,14}" name="phone" class="contact-form-input" placeholder="Telefon">
                <textarea name="message" class="contact-form-text"
                          placeholder="Mesaj"><?php echo !empty($postData['message']) ? $postData['message'] : ''?></textarea>
                <button id="Trimite" type="submit" value="submit" name="contactSubmit" class="contact-submit">Trimite</button>
</form> 


Controller:

PHP Code:
public function sendEmail($mailData)
    {

        $to '[email protected]';
        $from $mailData['email'];
        $fromName 'asd.asd';
        $mailSubject 'Cerere de oferta trimisa de ' $mailData['name'];

        $mailContent '
            <h2>CERERE OFERTA</h2>
            <p><b>Name: </b>' 
$mailData['name'] . '</p>
            <p><b>Email: </b>' 
$mailData['email'] . '</p>
            <p><b>Phone: </b>' 
$mailData['phone'] . '</p>
            <p><b>Message: </b>' 
$mailData['message'] . '</p>
        '
;
        $this->load->library('email');
        $config['mailtype'] = 'html';
        $this->email->initialize($config);
        $this->email->to($to);
        $this->email->from($from$fromName);
        $this->email->subject($mailSubject);
        $this->email->message($mailContent);

        return $this->email->send() ? true false;
    

Contact Function:

PHP Code:
public function contact()
    {
        $this->load->helper('email');
        $data $formData = array();
        if ($this->input->post('contactSubmit')) {
            $formData $this->input->post();

            $this->form_validation->set_rules('name''Name''required');
//          $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
            $this->form_validation->set_rules('phone''Phone''required');
            $this->form_validation->set_rules('message''Message''required');

            if ($this->form_validation->run() == true) {
                $mailData = array(
                    'name' => $formData['name'],
                    'email' => $formData['email'],
                    'phone' => $formData['phone'],
                    'message' => $formData['message']
                );
                $send $this->sendEmail($mailData);
                if ($send) {
                    header('location: https://asd.asd/success');
                } else {
                    $data['status'] = array(
                        'type' => 'error',
                        'msg' => 'Mesajul nu a fost trimis, va rugam sa incercati din nou'
                    );
                }
            }
        }
        // Pass POST data to view
        $data['postData'] = $formData;

        // Pass the data to view
        $this->load->view('contact'$data);
    


Output:
Quote:
Code:
This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_631dd81404150
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

CERERE OFERTA
Name: test
Email: [email protected]
Phone: 1231231231
Message: test message


--B_ALT_631dd81404150
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


=3Ch2=3ECERERE OFERTA=3C/h2=3E
=3Cp=3E=3Cb=3EName: =3C/b=3Etest=3C/p=3E
=3Cp=3E=3Cb=3EEmail: =3C/b=3Etest=40test.com=3C/p=3E
=3Cp=3E=3Cb=3EPhone: =3C/b=3E1231231231=3C/p=3E
=3Cp=3E=3Cb=3EMessage: =3C/b=3Etest message=3C/p=3E

--B_ALT_631dd81404150--
Reply




Theme © iAndrew 2016 - Forum software by © MyBB