Jump to content

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 = "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

 

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.