Welcome Guest, Not a member yet? Register   Sign In
problem in sending html email in CI 2.0.2
#1

[eluser]Unknown[/eluser]
I am trying to send html email using smtp/gmail , but all emails are sending corrupted .
mean its sending sending in html ! but receiving completely messed up ...

but same code with same message is working great in ci 1.7.2


after checking email debugging output I found an interesting thing ..

this is part of email's header I am talking about :

...............
X-Priority: 3 (Normal)
Mime-Version: 1.0


Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable<!DOCTYPE HTML>
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8"&gt;
..................

As you can see the first line of html email ( mean DOCTYPE ) has gone in the same line with Content-Transfer-Encoding ! but this doesn't happen in ci 1.7.2

and surprisely after adding a new line in top of html message problem resolved! and email received in correct HTML format ...


header after adding new line in top of html message :
........................
X-Priority: 3 (Normal)
Mime-Version: 1.0


Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML>
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8"&gt;
........................

the sending code / html message and email configuration are the same in borth ci 2.0.2 and 1.7.2
#2

[eluser]jtrainaldi[/eluser]
I am experiencing the same issue. Letters are being replaced with = signs every time.


The message email should read
"You have been requested to fill out the form. Click on the link below to fill out the report.
Report Form Link"

But it keeps on coming out like
"You have been requested to fill out th= form. Click on the link below to fill out the report. Report F=rm Link"

Anythoughts?
#3

[eluser]John Murowaniecki[/eluser]
Code:
$emails = array(
    'to'    => array('[email protected]'),
    'bcc'    => array('[email protected]')
);
$data = array(
    'name'        => $auth->name,
    'email'        => $auth->email,
    'created'    => $auth->created
);
$body = $this->load->view('mail/new_member', $data, TRUE);
$this->load->library('email');
$config = array(
    'mailtype'    => 'html',
    'charset'    => 'utf-8'
);
$this->email->initialize($config);
$this->email->from('[email protected]', 'Etcetera Robot');
$this->email->to($emails['to']);
$this->email->bcc($emails['bcc']);
$this->email->subject("New member: $auth->name");
$this->email->message($body);
#
$this->email->send();

..are working for me in some clients using CI 1.6, 1.7 and (actually) 2.0.. Almost the same code preserved.

All files (¬¬ view`n controller, in this case) are UTF-8 encoded..

Can you post your code?
#4

[eluser]John Murowaniecki[/eluser]
Hey guys, yesterday I have a issue with sending html formated mail using CI 1.7.2 - however the same script works on the development environment (my server) but not on the production (GoDaddy).

My development environment is an Ubuntu server running PHP 5.2.10-2ubuntu6.7, Apache 2.2.12 and sendmail with most basic configuration as possible. The GoDaddy has basicly the same configuration with the only significant change on the SMTP configuration (relay-hosting.secureserver.net instead localhost).

When I set the mailtype to html I have this return
Code:
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  mail() [<a href='function.mail'>function.mail</a>]: Bad parameters to mail() function, mail not sent.</p>
<p>Filename: libraries/Email.php</p>
<p>Line Number: 1519</p>

</div>
..And when it´s only text the mail was sent normally - but when received, the mail (obviously) is unformatted.

Well, I think the problems are on the SMTP settings and I'm contacting the GoDaddy support soon as possible.

The script I use is
Code:
$lang = $this->language();
        #
        $emails = array(
            'to'    => array('[email protected]'),
            'bcc'    => array('[email protected]')
        );
        $fields = array('name', 'mail', 'subject', 'message');
        #
        foreach ( $fields as $field )
        $data[$field] = $this->input->post($field);
        #
        $body = $this->load->view("$lang/emails/contat", $data, TRUE);
        $this->load->library('email');
        $config = array(
            'mailtype'    => 'html',
            'charset'    => 'utf-8'
        );
        $this->email->initialize($config);
        $this->email->from('[email protected]', $data['name']);
        $this->email->reply_to($data['mail'], $data['name']);
        $this->email->to($emails['to']);
        $this->email->bcc($emails['bcc']);
        $this->email->subject($lang == 'en' ? 'Etc - Contact' : 'Etc - Contato');
        $this->email->message($body);
        #
        die(print(json_encode(array('success' => $this->email->send() ? TRUE : FALSE))));
#5

[eluser]CodeIgniteMe[/eluser]
Use a third party script if you desire. I use PHPMailer and/or SwiftMail and doesn't have problems like this. And also, they are totally customizable.




Theme © iAndrew 2016 - Forum software by © MyBB