playground Posted October 13, 2015 Share Posted October 13, 2015 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.ukor <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 nothingin 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 aswelcome@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 :-)playgroundplayground@protonmail.ch Quote Link to comment https://forums.phpfreaks.com/topic/298560-php-mail-works-to-gmail-but-not-to-yahoo-and-not-to-protonmail/ Share on other sites More sharing options...
otuatail Posted October 13, 2015 Share Posted October 13, 2015 Would need to see the code around this. mail() is an funny thing. getting \n\r and the like. Also I have struggled with the likes of AOL. if you don't have a reverse DNS. I found a code snippet of mail separate and tested can show things up. Quote Link to comment https://forums.phpfreaks.com/topic/298560-php-mail-works-to-gmail-but-not-to-yahoo-and-not-to-protonmail/#findComment-1523142 Share on other sites More sharing options...
valandor Posted October 13, 2015 Share Posted October 13, 2015 (edited) 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 October 13, 2015 by valandor Quote Link to comment https://forums.phpfreaks.com/topic/298560-php-mail-works-to-gmail-but-not-to-yahoo-and-not-to-protonmail/#findComment-1523143 Share on other sites More sharing options...
otuatail Posted October 13, 2015 Share Posted October 13, 2015 Can you send yourself an email using different providers hotmail, google etc. Sounds like your code is fine to me it is the emailing providers that are the problem. If so that is an area you might be stuck on. Still could see the code itself. Quote Link to comment https://forums.phpfreaks.com/topic/298560-php-mail-works-to-gmail-but-not-to-yahoo-and-not-to-protonmail/#findComment-1523159 Share on other sites More sharing options...
playground Posted October 14, 2015 Author Share Posted October 14, 2015 (edited) 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 October 14, 2015 by playground Quote Link to comment https://forums.phpfreaks.com/topic/298560-php-mail-works-to-gmail-but-not-to-yahoo-and-not-to-protonmail/#findComment-1523240 Share on other sites More sharing options...
mac_gyver Posted October 14, 2015 Share Posted October 14, 2015 (edited) 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 October 14, 2015 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/298560-php-mail-works-to-gmail-but-not-to-yahoo-and-not-to-protonmail/#findComment-1523248 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.