Jump to content

php mail(...) works to gmail, but not to yahoo, and not to protonmail


playground

Recommended Posts

Hi there,

I hope someone can help me with this.
My php mail(..) code appears to be working just fine when sending to my gmail account.
(1) mail(...) returns TRUE and
(2) when i look in my gmail account i can see the emails arrive.
So... from this i conclude that my php email code is working fine.

however, when i change the receiver's email address to <user>@yahoo.co.uk
or <user>@protonmail.ch the emails never arrive.
mail(...) returns TRUE.... but the emails never arrive.

I imagine that my emails are being spam filtered.... but... there's nothing
in the spam folders of either <user>@yahoo.co.uk nor <user>@protonmail.ch.
So perhaps this filtering is going on before it reaches yahoo/protonmail ??

I'm running php currently off my local machine.

It doesn't seem to matter whether i specify the 'FROM' field as
welcome@vanilla.com or welcome@chit-chat.ch
(i get consist results, it works for gmail, but not for yahoo and protonmail)

Any help... suggestions... or the correct answer ;-)
would be gratefully appreciated :-)

playground

playground@protonmail.ch
Link to comment
Share on other sites

Email can be a tricky matter. Sometimes things don't make it to a mailbox because it makes spam filters go off, which is an issue I've had. I contacted my host and they ran a test on the emails I previously sent. They rated the emails on their spam filter and gave me excellent advice to fix my issues.

 

So I would suggest starting there if your host is willing.

Edited by valandor
Link to comment
Share on other sites

The code is bog standard, nothing strange or unusual about it:

 

    $to='playground@protonmail.ch';
    $subject='This Is a test email to playground';
    $body='Hi, this is an email content';
    $headers='From: welcome@vanilla.com';

    if(mail($to,$subject,$body,$headers))
    {
        echo 'mail(..) returned true';
    }
    else
    {
        echo 'mail(..) returned false';
    }

Edited by playground
Link to comment
Share on other sites

just because the mail() function is returning a true value, doesn't mean that the sending mail server has sent or has any intention of sending the email. some mail servers are configured to return a true value/no errors to php regardless of what happens to the email so as to not allow hackers to use the returned errors to find mail box names...

 

next, the yahoo/protonmail email servers may be doing a more thorough check of the DNS records at your web hosting than what gmail is doing (any chance you are using google web hosting so that sending an email to gmail is coming from a google server and the sending mail server is the same as the receiving mail server?). the ONLY information a receiving mail server gets with any email is the ip address of the server/device the email is being sent from (from the tcp/ip data packets) and information in the email, i.e. the from address. the receiving mail server will use these two pieces of information to try and validate that the email is actually coming from where it says it is by checking the DNS records at the sending ip address and at the domain in the from address. perhaps the yahoo/protonmail mail servers are looking for a secondary piece of information that gmail isn't and something is either missing (missing values usually aren't a problem) or is set incorrectly (incorrect values will get an email discarded.)

 

at a minimum, there should be an SPF DNS zone record at the domain being used in the from: mail header that indicates the sending mail server is authorized to send email for that domain.

 

you can check your DNS records and test your sending mail server for configuration problems at a site like dnsstuff.com

 

edit: if this is for a contact form, where you will always be sending to a single email address, you can use SMTP authentication (i.e. provide the access password for the mail box) against a receiving email address and send the emails directly to the mail server where the email address is hosted at. to use SMTP authentication, you will need to exchange smtp commands with the mail server. the phpmailer/swiftmailer classes handle this for you.

Edited by mac_gyver
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.