Jump to content

Correct MIME Headers for Mail::factory


ProblemHelpPlease
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...