Forum Moderators: coopster

Message Too Old, No Replies

php html email curiosity

question in a not so serious problem

         

omoutop

7:14 am on Feb 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



HI all,

i am not a great fan of sending email from site/form. Yet a client of mine insisted in getting some reports, so i have to make some script that do that, send html email to him.

I was clueless to that, so i start reading articles, tutorials and manuals. Some time later the job was done.

Now the question : in almost all reading material I have seen the $headers attribute being used. While in my case it only works as $header attribute (when i use it as $headers, it wont work, either error message or send plain text mail with the html code in it).

Why this is happening? The server the application is hosted runs apache 1.3 and php 4.3. Any suggestions?

coopster

4:40 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think you need to have a closer look at the mail() [php.net] function. The optional 'additional_headers' argument to that function is what you seem to be hung up on. There is a simple example on that page and there is also a Zend tutorial link on that page that might clarify some of your questions.

omoutop

7:07 am on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well i have read the manual as i said... Accordint to that example :

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

Which most tutorials also use..

In my case, if i use $headers, it just dont work (send text email with html code in body of text). I must use it as $header in order for mail to work.

DrDoc

7:58 am on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to specify 8-bit encoding.

And this header:
Content-Transfer-Encoding: 8bit

omoutop

8:16 am on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks for advise doc.... now off to test this :)