Welcome Guest, Not a member yet? Register   Sign In
CI 2 Email problems
#1

[eluser]dudeami0[/eluser]
When trying to create a html email, I get a blank message in Thunderbird. I tested it with plain text and it works fine. I'm using a local Mercury installation.

Anyways, this is my code:

Code:
$html = $this->load->view('email', '', true);

$config = array();
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['useragent'] = 'Gfxtub.com';

$this->load->library('email');
$this->email->initialize($config);
$this->email->to("kris@localhost");
$this->email->from("admin@localhost");
$this->email->subject("Hello World (No attach)");
$this->email->message($html);
$this->email->send();

echo $this->email->print_debugger();

And this is the output of the debugger

Code:
Your message has been successfully sent using the following protocol: mail

User-Agent: CodeIgniter
Date: Tue, 9 Nov 2010 21:04:24 -0500
From:
Return-Path:
Reply-To: "admin@localhost"
X-Sender: admin@localhost
X-Mailer: Gfxtub.com
X-Priority: 3 (Normal)
Message-ID: <4cd9fda874c57@localhost>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4cd9fda874c62"

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

--B_ALT_4cd9fda874c62
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

This is a test!


--B_ALT_4cd9fda874c62
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
=?utf-8?Q?Hello_World_(No_attach)?=
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Gfxtub.com&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    <b>This is a test!</b>
&lt;/body&gt;
&lt;/html&gt;

--B_ALT_4cd9fda874c62--

I noticed that the output of the HTML does not have a new line after the headers (Which I think I remember being a bit important, maybe not though). Any help would be much appreciated Smile
#2

[eluser]novice32[/eluser]
Not sure if this will solve your problem, but in my case, the boundary characters (--B_ALT_4cd9fda874c62--) would always show in the email footer when viewed in Outlook express (testing locally on Win 7, XAMPP). I read the Email.php core class to see how "send_multipart" is set. By default, it's TRUE. I set it to FALSE, and my boundary line no longer showed. While not in the CI User Guide as a parameter, you can set send_multipart just like the other settings (i.e.
Code:
$config_email['send_multipart'] = FALSE;
)
#3

[eluser]dudeami0[/eluser]
Hmm, seems kinda of the opposite of what I want to do. I need to send a HTML and Plain Text email, possibly with some attachments. If I disable send_multipart that gets rid of that functionality, or am I misunderstanding it?
#4

[eluser]novice32[/eluser]
I don't believe Multipart is related to attachments but rather backwards compatibility. I got the below from Wikipedia (http://en.wikipedia.org/wiki/MIME#Multipart_subtypes):

Most commonly, multipart/alternative is used for e-mail with two parts, one plain text (text/plain) and one HTML (text/html). The plain text part provides backwards compatibility while the HTML part allows use of formatting and hyperlinks. Most e-mail clients offer a user option to prefer plain text over HTML; this is an example of how local factors may affect how an application chooses which "best" part of the message to display.
#5

[eluser]novice32[/eluser]
I do see the need where you want plain text option as well. Not sure what to suggest next.
#6

[eluser]dudeami0[/eluser]
Edit: Misunderstood some things :p

Hmm.. I'll probably just end up making a custom library to handle emailing :p This is causing alot of trouble for me :S

Thanks for the help though Smile
#7

[eluser]InsiteFX[/eluser]
I use this one and have never had a prolem with testing emails.

Test Mail Server Tool for Windows

InsiteFX
#8

[eluser]dudeami0[/eluser]
Hmm, still getting problems with it. I just ended up making a custom email class to use.

Also, thanks for the tool InsiteFX, very nice Smile
#9

[eluser]InsiteFX[/eluser]
Try taking this out, defaults to Codeigniter.
Code:
$config['useragent'] = 'Gfxtub.com';

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB