Calamity-Clare Posted February 1, 2010 Share Posted February 1, 2010 I am making a form that sends mail to 2 different recipients once the user has completed it. The first recipient is set as the owner of the website & it sends him all the information the user filled out in the form. The second is for the user who filled out the form, it's just a nice courtesy email thanking them for filling in the form. My client is big on pretties. So I'm trying to make the form send the email in HTML. So far, I've got it working fine sending as plain text (although hotmail has issues with my from field, frustrating. Although I read somewhere on the big wide web that hotmail just hates php email in general, is this correct?) This is the script for the mail function: $headers = 'Reply-To: [email][email protected]'[/email] . "\r\n"; $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1" . "\r\n"; // Email #1: Create the email body as a text message to Client $to1 = "[email][email protected][/email]"; $message1 = '<html><body><img src="header_email.jpg" alt="" width="1000" height="162" border="0" /><p style="font-family:"Myriad Pro", "Helvectica", "Arial", "Sans-serif"; font-size:13px;">$body1</p></body></html>'; $body1 = "Submission of interest in attending seminars from $name. \n\n Information received: \n Seminar Attending: $month, \n Interest: $interest, \n Title: $title, \n Name: $name, \n Address (Line 1): $address1, \n Address (Line 2): $address2, \n Suburb/Town: $suburbtown, \n State: $state, \n Postcode: $postcode, \n Contact Number: $contactnumber, \n Email Address: $email, \n Number of Attendees: $numberattendees, \n Additional Queries or Comments: $additionalqueries."; $subject1 = "Newly submitted form"; $from1 = "$name <$email>"; // Create the email body as a text message to Form User $to2 = "$name <$email>"; $message2 = '<html><body><img src="header_email.jpg" alt="" width="1000" height="162" border="0" /><p style="font-family:"Myriad Pro", "Helvectica", "Arial", "Sans-serif"; font-size:13px;">$body1</p><p style="font-family:"Myriad Pro", "Helvectica", "Arial", "Sans-serif"; font-size:10px;">$disclaimer2</p></body></html>'; $body2 = "Thank you, $name for registering your interest in learning more about and attending our $month educational program. We will contact you shortly with further detailed information about the seminars. \n\n Have a good day! \n Kind regards, \n Peter Dousek"; $disclaimer2 = "This email (including all attachments) is the sole property of Options Trading Australia \and may be confidential. \If you are not the intended recipient, you must not \use \or forward the information contained in it. This message may not be reproduced \or otherwise republished without the written consent of the sender. \If you have received this message in error, please \delete the e-\mail \and notify the sender."; $subject2 = "Thank you for your interest in Options Trading Australia's Seminars"; $from2 = "Options Trading Australia <[email][email protected][/email]>"; // Send the data in an email to Client mail ( "$to1", "$subject1", "$message1", "From: $from1", "$headers" ); // Send the data in an email to Form User mail ( "$to2", "$subject2", "$message2", "From: $from2", "$headers" ); When I include the headers, neither of the recipients receives an email at all. I've referenced several websites, & I thought I had it right, yet it doesn't work, so I can't have lol. Is there anything wrong with this script? Also, is there any reason that hotmail will receive email from this sender: $from2 = "Options Trading Australia <[email protected]>"; or: $from2 = "Options Trading Australia"; but NOT from: $from2 = "Options Trading Australia <peterdousek@optionstradingaustralia.com.au>";?? (I've attached the full php file.) Thank you [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/190529-mail-function-not-recognising-headers/ Share on other sites More sharing options...
trq Posted February 2, 2010 Share Posted February 2, 2010 You are passing your headers to the fifth argument, they belong in the fourth. Your From section also belongs in your headers, its not a separate parameter. Link to comment https://forums.phpfreaks.com/topic/190529-mail-function-not-recognising-headers/#findComment-1005329 Share on other sites More sharing options...
Calamity-Clare Posted February 2, 2010 Author Share Posted February 2, 2010 Ohhh that's something I didn't realise. Thank you! BUUUT ... I changed it & it didn't help ... :S Updated Code: $headers = 'From: Options Trading Australia' . "\r\n"; $headers .= 'Reply-To: [email protected]' . "\r\n"; $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1" . "\r\n"; // Email #1: Create the email body as a text message to Client $to1 = "[email protected]"; $message1 = '<html><body><img src="header_email.jpg" alt="" width="1000" height="162" border="0" /><p style="font-family:"Myriad Pro", "Helvectica", "Arial", "Sans-serif"; font-size:13px;">$body1</p></body></html>'; $body1 = "Submission of interest in attending seminars from $name. \n\n Information received: \n Seminar Attending: $month, \n Interest: $interest, \n Title: $title, \n Name: $name, \n Address (Line 1): $address1, \n Address (Line 2): $address2, \n Suburb/Town: $suburbtown, \n State: $state, \n Postcode: $postcode, \n Contact Number: $contactnumber, \n Email Address: $email, \n Number of Attendees: $numberattendees, \n Additional Queries or Comments: $additionalqueries."; $subject1 = "Newly submitted form"; // Create the email body as a text message to Form User $to2 = "$name <$email>"; $message2 = '<html><body><img src="header_email.jpg" alt="" width="1000" height="162" border="0" /><p style="font-family:"Myriad Pro", "Helvectica", "Arial", "Sans-serif"; font-size:13px;">$body1</p><p style="font-family:"Myriad Pro", "Helvectica", "Arial", "Sans-serif"; font-size:10px;">$disclaimer2</p></body></html>'; $body2 = "Thank you, $name for registering your interest in learning more about and attending our $month educational program. We will contact you shortly with further detailed information about the seminars. \n\n Have a good day! \n Kind regards, \n Peter Dousek"; $disclaimer2 = "This email (including all attachments) is the sole property of Options Trading Australia \and may be confidential. \If you are not the intended recipient, you must not \use \or forward the information contained in it. This message may not be reproduced \or otherwise republished without the written consent of the sender. \If you have received this message in error, please \delete the e-\mail \and notify the sender."; $subject2 = "Thank you for your interest in Options Trading Australia's Seminars"; // Send the data in an email to Client mail ( "$to1", "$subject1", "$message1", "$headers" ); // Send the data in an email to Form User mail ( "$to2", "$subject2", "$message2", "$headers" ); Link to comment https://forums.phpfreaks.com/topic/190529-mail-function-not-recognising-headers/#findComment-1005340 Share on other sites More sharing options...
trq Posted February 2, 2010 Share Posted February 2, 2010 Firstly, the From header should be a valid email address on the server sending the email. As for the html, your images need to be a complete url to the image as they are not actually sent with the email. Are you sure its not being received in html form? You also have $disclaimer2 within a single quoted string, this will not be interpolated, also, these lines.... mail ( "$to1", "$subject1", "$message1", "$headers" ); should be.... mail ($to1, $subject1, $message1, $headers); There is simply no need for the quotes. You might also try turning on error reporting & display errors to make sure your not getting any errors. Link to comment https://forums.phpfreaks.com/topic/190529-mail-function-not-recognising-headers/#findComment-1005342 Share on other sites More sharing options...
Calamity-Clare Posted February 2, 2010 Author Share Posted February 2, 2010 Thanks for your reply Thorpe. At first I was receiving the email with the html script visible in the message. I made some changes, now I'm not getting anything. I have both error reporting turned on & the display set to strict, it's at the top of the code. I have only showed you the code that's not working. Ok, so ... From header ... check Image sourced from a url ... check Remove quotes from mail function ... check You also have $disclaimer2 within a single quoted string, this will not be interpolated What exactly do you mean by that. $disclaimer2 is in double quotes, but $message2 is not & I didn't think I could do that. If I put it in double quotes, it messes with the quotes inside the html ... will it still work if I do it anyway? Link to comment https://forums.phpfreaks.com/topic/190529-mail-function-not-recognising-headers/#findComment-1005365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.