marckeeley Posted September 5 Share Posted September 5 I'm trying to get php mail() working with gmail. It sends the message to my domain fine however it isn't received if I change it to my gmail address. I did try PHPMail but read here that uses mail(), so that didn't work either. Does anyone know a way around it? Thanks <?php echo "About to send test email...<br />"; $to = "XXXXXX@gmail.com"; $subject = "Test Mail"; $message = "Hello world!"; $headers = "From: YYYYYYY.helioho.st"; $success = mail($to, $subject, $message, $headers); if ($success) { echo "Mail sent successfully...<br />"; } else { echo "*** Mail could not be sent...<br />"; } ?> Link to comment Share on other sites More sharing options...
KazVee Posted September 5 Share Posted September 5 Have you tried a test email with more realistic content, and not things like "test email / hello world"? I noticed during some of my own email testing that Gmail's filters will prevent things like that from even being put into the spam folder, they just go into a black hole. But when my test emails contained a quick pretend update about groceries needed or making dinner plans, I had better success at getting my messages received to my Gmail account. Link to comment Share on other sites More sharing options...
marckeeley Posted September 5 Author Share Posted September 5 Thank you for the suggestion. I just changed the subject and body to something more realistic in a couple of different ways but they still didn't get through. Link to comment Share on other sites More sharing options...
wolstech Posted September 5 Share Posted September 5 Gmail does not accept email from us by default because SPF and DKIM are not set up unless you request it (or you can set them up yourself if you're using external DNS). If you send mail from a mailbox in Plesk's webmail, you'll get a message back from Google explaining this. For automated emails such as from mail() it will report a success yet never arrive. There's no mailbox on the sending end, so your email gets sent, Google throws it out, and you can't receive the error back. PHP will report a success since mail() returns true when the send succeeds, not when it delivers, ...PHP doesn't care about, and has no way of knowing, that the receiving end discarded what it sent. The fix for this is usually to set a From address in the mail command (e.g. set the header paramater to "From: noreply@marckeeley.helioho.st"), then request that SPF and DKIM be set up for marckeeley.helioho.st. Do you want me to get SPF and DKIM set up for your domain? Link to comment Share on other sites More sharing options...
marckeeley Posted September 5 Author Share Posted September 5 Thanks for the explanation. Yes please regarding the SPF & DKIM. Thank you. Link to comment Share on other sites More sharing options...
wolstech Posted September 6 Share Posted September 6 Escalating since I'm not at a PC. Either me or Krydos will get to this for you at some point today. 1 Link to comment Share on other sites More sharing options...
Krydos Posted September 6 Share Posted September 6 DKIM, SPF, and DMARC have been set up for the domain marckeeley.helioho.st. We recommend sending a test email to https://www.mail-tester.com/ to make sure that everything is set up correctly. If you get less than a 10/10 score please post a link to the full report so we can help you fix any other issues that there may be. 1 Link to comment Share on other sites More sharing options...
Recommended Posts