• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Email message is always sent as plain text and the body is full of weird code

#1
[eluser]landitus[/eluser]
Hi, I've been sending an activation email after a form submit and every time the email I get shows exactly this:

Code:
Reply-To: "[email protected]" <[email protected]>
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Date: Thu, 26 Apr 2012 21:12:28 -0300 (ART)

Click the link below to activate your account<a
href="http://www.url.com/confirm/3b80246747e8d30e82269233b7a08f26/">Confirm</a>


As you can see it's like the headers are all over the place. I tried setting the email as plain and html, but it's the same. I'm testing this locally, with MAMP and sending with gmail (SMTP).

This is my email config:

Code:
$config['protocol'] = 'smtp';
   $config['smtp_host'] = 'ssl://smtp.gmail.com';
   $config['smtp_port'] = 465;
   $config['smtp_timeout']='30';
   $config['smtp_user'] = '[email protected]';
   $config['smtp_pass'] = 'xxxxxxxx';
   $config['mailtype']  = 'text';
   $config['charset']   = 'utf-8';
   $config['crlf'] = "\r\n";
   $config['newline'] = "\r\n";

What can I do?


#2
[eluser]CroNiX[/eluser]
When sending it as html, do you use html and body tags like it's supposed to have?

#3
[eluser]landitus[/eluser]
No, I'm going to try that. What's weird is that no matter what mailtype I try, the debugger shows it's Content-type is text/plain. Also, It says it's using the mail protocol, which it's not. Is this a bug?

#4
[eluser]landitus[/eluser]
This is the body of the email with the html tags. Still wrong. Sad

Code:
Reply-To: "[email protected]" <[email protected]>
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Date: Thu, 26 Apr 2012 22:00:43 -0300 (ART)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">&lt;html&gt;head>
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="viewport" content="width=device-width,
initial-scale=1.0"/&gt;&lt;title>Click the link below to activate&lt;/title&gt;&lt;/head>&lt;body&gt;Click the link below to activate your
account<a
href="http://www.url.com/confirma/bf74a8db4482f0c46c452be95b482644/">Confirm√°
tus entradas</a>&lt;/body&gt;&lt;/html>

#5
[eluser]Sumeet Kashyap[/eluser]
While initializing the class, remove "\r\n" for crlf and newline. It should work then.

So it should be:

Code:
$config['protocol'] = 'smtp';
   $config['smtp_host'] = 'ssl://smtp.gmail.com';
   $config['smtp_port'] = 465;
   $config['smtp_timeout']='30';
   $config['smtp_user'] = '[email protected]';
   $config['smtp_pass'] = 'xxxxxxxx';
   $config['mailtype']  = 'text';
   $config['charset']   = 'utf-8';

#6
[eluser]InsiteFX[/eluser]
Code:
// wrong!
$config['mailtype']  = 'text';

// should be.
$config['mailtype']  = 'html';

$this->email->set_alt_message()

Sets the alternative email message body:
$this->email->set_alt_message('This is the alternative message');

This is an optional message string which can be used if you send HTML formatted email.
It lets you specify an alternative message with no HTML formatting which is added to the
header string for people who do not accept HTML email. If you do not set your own message
CodeIgniter will extract the message from your HTML email and strip the tags.

Then use set_alt_message()

#7
[eluser]landitus[/eluser]
It turns out it had to do with a conflict with Ion Auth (I had it in my autoload) which overrode the email library configuration in this very case. Thankfully, I told Ben of Ion Auth about it and he already got it fixed!! Thanks Ben!

#8
[eluser]alexman[/eluser]
Could you post a link to the bugfix, which code needed to be tweaked and/or which version it was fixed in?
Thanks


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme ¬© 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.