ProblemHelpPlease Posted February 22, 2012 Share Posted February 22, 2012 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 More sharing options...
justsomeguy Posted February 22, 2012 Share Posted February 22, 2012 Are you using the PEAR Mail package? Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted February 23, 2012 Author Share Posted February 23, 2012 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 More sharing options...
justsomeguy Posted February 23, 2012 Share Posted February 23, 2012 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 More sharing options...
ProblemHelpPlease Posted February 23, 2012 Author Share Posted February 23, 2012 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 More sharing options...
justsomeguy Posted February 23, 2012 Share Posted February 23, 2012 All headers are accepted, it doesn't do any validation checking that I'm aware of. You can add any header you want with any value. The mail client might not understand the header but the mail package doesn't care. Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted February 23, 2012 Author Share Posted February 23, 2012 Ill try and run a few tests with the headers I require and see what different email clients make of them. You dont happen to know where I can find a list of all the different header types and values that can be used when sending mail. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2012 Share Posted February 23, 2012 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.