php mail function: legitimate mails marked as spam by gmail and hotmail

后端 未结 2 588
日久生厌
日久生厌 2020-12-03 19:13

My website sends emails to users using the PHP mail function. Hotmail and Gmail users don\'t receive them, or they end up in SPAM-folder. Here is the header of a message mar

相关标签:
2条回答
  • 2020-12-03 19:41

    Your envelope adress doesnt match the from adress. This is the main reason why mails are regarded as spam.

    The background is: The envelope adress (in your case admin@drt01.dco.fusa.be) isn't really visible to the user. Its just used by mailservers to return error mails. Historically because they are more relevant to the admin than to the user. However today its de-facto standard to set the envelope address to the same as the user address. Spammers don't really do that because they either don't have the possibility to or they don't want to recieve all the backbouncing error mails when sending spam. Or they don't want the exploited users with the trojan worm be aware of their evil-doing.

    In php/sendmail this function is called the f parameter. You can read all about that in the function documentation: http://php.net/manual/en/function.mail.php

    Classes like phpmailer or libmail do this their selves and its probably the best idea to use one of theese because they have been tested, are well designed and react to changes in their developement!

    The next thing you could do is to set the reverse-dns to the same domain that the sender adress is. If you do this you are really, really trustworthy because the mail can be matched to a server and thus to a provbider/admin and could be easily blacklisted by spam networks. So if you would spam with a correctly set up reverse dns you wouldnt do it long. There is a built-in directive in arpa rulse that the set up of such an entry takes a while so it cant be made somehow danymically and exploited.

    This is however rather advanced and there can only be one reverse dns entry per ip adress. So you can't do it on a shared hosting environment. You also have to contact your provider to set them up but you can google for all that stuff.

    Sum up:

    • correct your envelope adress, that should be fine
    • if you can, set a reverse dns entry

    PS: there are not really rules how and when to regard a mail as spam and the teqniques above have only proven to work in praxis but there is absolutely no guarantee. Every mail provider can do what he wants... (yahoo was one of theese candidates to do their very own thing and to annoy everybody with it in the past)

    good luck

    0 讨论(0)
  • 2020-12-03 19:48

    Try using google apps and setting up the spf record, going to setting -> security and setting up the txt dkim key. Then setup the mx records, etc. do all of this on a subdomain of your domain (eg, int.domain.com) and then use smtp to send the mail from phpmail after signing into the account in google, clicking the settings button on right, click settings, php/imap, and enabling both.

    This always works for me and they never get marked as spam because they come from google's servers and have a valid header, return path, sender, smtp, spf record, txt dkim record, mx records, etc.

    Try that out and let me know if it works :)

    0 讨论(0)
提交回复
热议问题