Jump to content

Mail() not working!


ukweb

Recommended Posts

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 = "[email protected]";
$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

 

 

Link to comment
https://forums.phpfreaks.com/topic/73655-mail-not-working/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/73655-mail-not-working/#findComment-371624
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.