ukweb Posted October 17, 2007 Share Posted October 17, 2007 Hi I have the following code. When I test it I get the success message and not the fail but I don't receive the email in my inbox so I don't know whats going on here with it really. I'm hosted with media temple and as far as I can see everything is coded correctly. if ($_POST['action'] == 'send_enquiry') { $to = "stephen@sjwright.co.uk"; $subject = $_POST['subject']; $formattedbody = "ClickCMS: You have received an enquiry from ".$_POST['e_name']." (".$_POST['e_email']."). \n Subject: ".$_POST['subject']."\n Contact: ".$_POST['e_number']."\n Property: ".$_POST['property_id']."\n Message: \n".$_POST['e_enquiry']."\n\n ClickCMS Message Service 2006-2007 sjwright.co.uk"; $message = wordwrap($formattedbody, 70); if (mail($to, $subject, $message)) { $msg = "Message successfully sent"; } else { $msg = "Enquiry failed to send"; } } Any help is received with thanks Stephen Quote Link to comment https://forums.phpfreaks.com/topic/73655-mail-not-working/ Share on other sites More sharing options...
kenrbnsn Posted October 17, 2007 Share Posted October 17, 2007 Although the fourth parameter to the mail() function is listed as "optional", most mail program will reject your email if there isn't a "From:" header in the email message. This header is entered in the fourth parameter as: <?php $headers = "From: Your Name <your.email@address>"; if (mail($to, $subject, $message,$headers)) { $msg = "Message successfully sent"; } else { $msg = "Enquiry failed to send"; } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/73655-mail-not-working/#findComment-371624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.