Jump to content

PHP Mail help


Recommended Posts

This is weird and happens a lot.

 

When I send an email from a php script

mail("email@gmail.com","Literature Request",$msg);

 

I receive the email in my GMAIL account, no problem. But when sending to any other email address (that ISN'T GMAIL), it doesn't get received. Not even in the spam folder.

 

Whats up with that?

 

Wes

Link to comment
Share on other sites

Hotmail and Yahoo are notorious for this. It's basically their spam filters blocking the email.

 

You haven't set any headers or the senders address, that is probably why they aren't being received, the spam filters just drops it.

 

What I normally do to ensure the email gets through is set the  from, reply-to and return path headers. Often the senders email address needs to be on the same server as the web server, and it also helps if the email account does actually exist.

 

  $headers = "From: mail@site.co.uk\r\n";
  $headers .= "Reply-To: mail@site.co.uk\r\n";
  $headers .= "Return-Path: mail@site.co.uk\r\n";

  $success = mail($to, $subject, $body, $headers);

Link to comment
Share on other sites

Negatory, here's the new code:

 

$headers  = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "From: email@amil.com \r\n";
$headers .= "Reply-To: email@amil.com \r\n";
$headers .= "Return-Path: email@amil.com \r\n";
mail("me@gmail.com,another@mydomain.com","Literature Request",$msg,$headers);

Link to comment
Share on other sites

  • 4 weeks later...

I do not want to hijack your post, but I too, have this issue. The only thing that is differnet is, I am trying to let others email me via a form on my page. I only get success when I test it with emails addys that are on my domain. Any other email ( they do exist ) from my isp or yahoo or gmail all gets failed response. Is this the same cause?

 

P.S. I am really a newbie to this.

Link to comment
Share on other sites

Ok,  I don't know if this is a bad thing, but I changed the "from" field of my php to be "myemail@mywebsite.com" I left the rest of it the same and it seems to work 100% so far. I need to know if there is a better way. I can post the entire PHP if you'd like. It is very basic

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.