By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

PHP create HTML email inserts '!'s

P: n/a
OK,

I'm trying to create an email and when it sends the email, it mostly
works except that there are '!' inserted at some spots. Checking the
html source of the email, looks like they are placed at the end of
long lines. I'm assuming there is some issue with the encoding, but
searching through groups, nothing I've tried has worked. Can someone
let me know if I should be doing something differently with my headers
for an html email? I'll change emails to nu**@null.com. Thanks!

$headers = "X-Mailer: PHP " . phpversion() . "\r\n";
$headers .= "From: nu**@null.com\r\n";
$headers .= "Reply-To: nu**@null.com\r\n";
$headers .= "Content-Type: text/html;\r\n";
$headers .= "charset=\"iso-8859-1\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";

Feb 7 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hello,

on 02/07/2007 05:03 PM geek7 said the following:
OK,

I'm trying to create an email and when it sends the email, it mostly
works except that there are '!' inserted at some spots. Checking the
html source of the email, looks like they are placed at the end of
long lines. I'm assuming there is some issue with the encoding, but
searching through groups, nothing I've tried has worked. Can someone
let me know if I should be doing something differently with my headers
for an html email? I'll change emails to nu**@null.com. Thanks!

$headers = "X-Mailer: PHP " . phpversion() . "\r\n";
$headers .= "From: nu**@null.com\r\n";
$headers .= "Reply-To: nu**@null.com\r\n";
$headers .= "Content-Type: text/html;\r\n";
$headers .= "charset=\"iso-8859-1\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
I think you need to encode your message with MIME quoted-printable.

If you do not know how to compose MIME quoted-printable messages, you
may want to try this MIME message class:

http://www.phpclasses.org/mimemessage

It is also better to include an alternative plain text part using
multipart/alternative MIME parts. This is not related to you problem.
Just a comment after noticing you used Content-Type set to text/html .
The class above can also help solving that problem.

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Feb 7 '07 #2

P: n/a
geek7 wrote:
$headers .= "Content-Type: text/html;\r\n";
$headers .= "charset=\"iso-8859-1\"\r\n";
This is broken.

Should be either:

$headers .= "Content-Type: text/html; ";
$headers .= "charset=\"iso-8859-1\"\r\n";

or:

$headers .= "Content-Type: text/html;\r\n";
$headers .= "\tcharset=\"iso-8859-1\"\r\n";

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Feb 9 '07 #3

P: n/a
I have been struggling with this for a while now.. I did change the
errors like Toby said, and it did fix another problem I had, but I
still cannot figure out how to properly use the mimemessage class.
Does anyone have an example of this class encoding with quoted
printable? I'm sure the answer is in the documentation staring me in
the face, but I'm fairly new to PHP and can't get it. Thanks ahead of
time!

Derek

Mar 1 '07 #4

P: n/a
On Mar 1, 2:09 pm, "geek7" <dpoe...@gmail.comwrote:
I have been struggling with this for a while now.. I did change the
errors like Toby said, and it did fix another problem I had, but I
still cannot figure out how to properly use the mimemessage class.
Does anyone have an example of this class encoding with quoted
printable? I'm sure the answer is in the documentation staring me in
the face, but I'm fairly new to PHP and can't get it. Thanks ahead of
time!

Derek
I will suggest using this class and enjoy instead of wasting time on
email.
Here you can send html and text mail, both at a time also. client who
do not understand
html will display text msg. Work for attachment, and more.

phpmailer.sourceforge.net/

Mar 3 '07 #5

P: n/a
Hello,

on 03/01/2007 04:09 PM geek7 said the following:
I have been struggling with this for a while now.. I did change the
errors like Toby said, and it did fix another problem I had, but I
still cannot figure out how to properly use the mimemessage class.
Does anyone have an example of this class encoding with quoted
printable? I'm sure the answer is in the documentation staring me in
the face, but I'm fairly new to PHP and can't get it. Thanks ahead of
time!
Take a look at the test_simple_html_mail_message.php script that uses
the MIME message class to compose and send quoted-printable HTML
messages that avoid the ! problem.

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 4 '07 #6

P: n/a
On Mar 4, 1:17 am, Manuel Lemos <mle...@acm.orgwrote:
Hello,

on 03/01/2007 04:09 PM geek7 said the following:
I have been struggling with this for a while now.. I did change the
errors like Toby said, and it did fix another problem I had, but I
still cannot figure out how to properly use the mimemessage class.
Does anyone have an example of this class encoding with quoted
printable? I'm sure the answer is in the documentation staring me in
the face, but I'm fairly new toPHPand can't get it. Thanks ahead of
time!

Take a look at the test_simple_html_mail_message.phpscript that uses
the MIME message class to compose and send quoted-printableHTML
messages that avoid the ! problem.

http://www.phpclasses.org/mimemessage

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generatorhttp://www.metastorage.net/

PHPClasses - Free ready to use OOP components written inPHPhttp://www.phpclasses.org/

Manuel,

This helps a ton! I got the email to format correctly, but I have just
one more issue if you could help I would greatly appreciate it. I am
trying to add multiple addresses to the email I wrote. Looking in the
documentation, it says I can use:

$message_object->SetMultipleEncodedEmailHeader('Bcc', array(
'p****@gabriel.org' ='Peter Gabriel',
'p***@simon.net' ='Paul Simon',
'm***@chain.com' ='Mary Chain'
);

but When I do this, no one gets the email..same if I change 'Bcc' to
'To'. Do I need to change all my SetEncodedEmailHeader functions to
SetMultipleEncodedEmailHeader? Or is there an easy way to do multiple
addresses...(other than putting one in the to, cc, and bcc...) thanks!

Mar 7 '07 #7

P: n/a
Hello,

on 03/07/2007 01:20 PM geek7 said the following:
>>I have been struggling with this for a while now.. I did change the
errors like Toby said, and it did fix another problem I had, but I
still cannot figure out how to properly use the mimemessage class.
Does anyone have an example of this class encoding with quoted
printable? I'm sure the answer is in the documentation staring me in
the face, but I'm fairly new toPHPand can't get it. Thanks ahead of
time!
Take a look at the test_simple_html_mail_message.phpscript that uses
the MIME message class to compose and send quoted-printableHTML
messages that avoid the ! problem.

http://www.phpclasses.org/mimemessage
>
This helps a ton! I got the email to format correctly, but I have just
one more issue if you could help I would greatly appreciate it. I am
trying to add multiple addresses to the email I wrote. Looking in the
documentation, it says I can use:

$message_object->SetMultipleEncodedEmailHeader('Bcc', array(
'p****@gabriel.org' ='Peter Gabriel',
'p***@simon.net' ='Paul Simon',
'm***@chain.com' ='Mary Chain'
);

but When I do this, no one gets the email..same if I change 'Bcc' to
'To'. Do I need to change all my SetEncodedEmailHeader functions to
SetMultipleEncodedEmailHeader? Or is there an easy way to do multiple
addresses...(other than putting one in the to, cc, and bcc...) thanks!
Not getting messages when you set all to Bcc is normal. Many mail
filters do not like that. As for To: it should work . If it doesn't,
there may be some other problem.

You can also try set the To header with the SetHeader function, only
with e-mail addresses separated with commas , .

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 7 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.