Jump to content

Correct MIME Headers for Mail::factory


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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...