Jump to content

mail() help


unkwntech

Recommended Posts

I have the following code

//There were no emails so we need to send the email to Jarrod and tell the user it was sucessful.
$message = 'A quote was requested from your website today (' . date('D, JS') . 'of' . date('F Y') . ' at ' . date('g:i A') . ".\r\n";
$message .= 'Name: ' . $_POST['firstName'] . ' ' . $_POST['lastName'] . ".\r\n";
$message .= $_POST['firstName'] . ' can be contacted at ' . $_POST['phoneNumber'] . ".\r\n";
$message .= 'The best time to contact this person is between ' . $_POST['time1'] . ' and ' . $_POST['time2'] . ".\r\n";
$message .= "They said they need:\r\n" . $_POST['body'] . "\r\n\r\n";
$headers = 'From: EMAIL-REMOVED' . "\r\n" .
    'Reply-To: EMAIL-REMOVED';
if(mail('EMAIL-REMOVED', 'Quote Requested', $message, $headers))
 {
	echo 'Message sent';
 }
else 
 {
	echo 'Message failed';
 }

I have already validated the post values at this point, and I am seeing message sent but the message has not arrived at either email address specified, did I miss something?

Link to comment
Share on other sites

Give this a try but with your code

 

$to=enter_email_var_here;
$subject="enter subject here";
$name="enter var name here";
$message="Hi<br><br> ".$_REQUEST['name']." has requested info.<br><br>Thank you.";
mail("$to","$subject","$message","From: $name <$email>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");
header("Location: thanks.php");

Link to comment
Share on other sites

strange I use that exact bit of code on a lot of sites and it works fine, maybe there is another underlying issue that may be server configuration related?

 

its sent to it from a form as I assume you are doing, the only difference i see is I am using $_REQUEST instead of $_POST as you are, altho I am not entirely sure if thats the issue.

Link to comment
Share on other sites

A TRUE returned by the mail() function only means that the mail server that php has been configured to use exists and it accepted the email for sending without returning an error. It does not mean that the email was sent.

 

Due to outgoing spam/virus scanning that occurs after an email has been accepted, your email might not be sent. Also, because of scripts probing mail servers to find out server and user information, a lot of mail servers have been configured to "silently" accept emails that might violate relaying restrictions or have other problems without returning a failure status but that the mail server has no intention of sending.

 

And if your email is being sent by your sending mail server, the receiving email server might discard it if your sending mail server does not have proper DNS records associated with it or if you are doing something like using a From: address that is not hosted at the domain corresponding to the sending mail server or if there is not an SPF record at the domain in the From: address that says that your sending mail server is authorized to send email for that domain or if your sending mail server has been banned by the receiving mail server.

 

Here is a list of things to check -

 

Is the mail() function even enabled?

 

Are you meeting any relaying and SMTP authorization restrictions that your web host has set up?

 

Check the mail server logs and any outgoing spam/virus scanner logs to see what is happening with your email.

 

Is the To: address hosted at the sending mail server? Edit: are you sending this to a mail server at the web host or are you sending this to an external address?

 

Is the From: address hosted at the sending mail server?

 

Does the sending mail server have proper DNS records? You can check at dnsreport.com/dnsstuff.com

 

Has the sending mail server been banned by the receiving mail server or does the sending mail server appear on any of the spam databases?

Link to comment
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.