Jump to content

Correct MIME Headers for Mail::factory


ProblemHelpPlease

Recommended Posts

I am not sure of the correct way to use headers when sending mail over SMTP from within PHP. I was using PHP mail but now need to use SMTP authenification to send mail from within the code. The message body is currently using

$messagebody = rtrim(chunk_split(base64_encode($messagebody)));

So the headers need the correct encoding setting which was

$headers = "MIME-Version: 1.0" . "\r\n";$headers .= "Content-Transfer-Encoding: base64" . "\r\n";$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

when I was using PHP. How is this set when using SMTP as they require an array and do I need to call or set something else first.

Link to comment
Share on other sites

Yes, I am required to use the PEAR mail package to enable me to access SMTP due to the way the hosting is setup. I was previously using php mail so have not had any experience of using PEAR.I have a working test page for the mail but the code will be processing many different areas of a website and sending some important emails out so I need to be sure it is working correctly and its not my email client that is self correcting badly formed headers for me.

Link to comment
Share on other sites

One example of sending a mail is here, except to be correct the example should use this to initialize the headers array before it adds headers to it: $headers = array(); http://pear.php.net/...l.mail.send.php You can also initialize and set the values at the same time:

$headers = array(  'From' => 'test@test.com',  'Subject' => 'Test');

Link to comment
Share on other sites

I understand how to format the basic headers so they are in an array, my problem is I dont know what the correct way to set the relevant mime and content type headers is for an email that is base64 encoded when using pear mail. I dont want to pass headers to the pear mail script that it cant understand but I cant find any informtion that tells me what headers are accepted or what the correct format or order should be.I will try and post my current script when I get a chance.

Link to comment
Share on other sites

Any mail server is allowed to add any header it wants. There is a defined list of headers that have a specific meaning in the email specs, but the spec specifically allows anything to be sent. If the mail client doesn't recognize a header it ignores it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...