PHP mail() function does not work on web-host

前端 未结 5 1020
野趣味
野趣味 2021-01-26 00:25

I\'m having issues sending emails using the php mail() function. I know the php script I have works because I have an identical copy of it on another web-hosting company and it

5条回答
  •  日久生厌
    2021-01-26 01:10

    mail() function of php, will send your mail to junk only. Instead use SMTP php mailer function.

    Why we should use SMTP instead PHP mail():

    SMTP log in to an actual account on a mailserver and send the mail through SMTP to another mail server. If the mail server is configured correctly, your mails are sent from an actual account on a mailserver and will not wind up flagged as spam.

    Mail sent with the mail() function is sent with sendmail in most cases. There is no authentication going on and it will almost always be flagged as spam if you use the "From:" in the extra headers.

    This is because if you take a look at an original email file in say, gmail, you will see the headers that are sent. You are actually sending from user@serverhostname.tld and not someone@example.com like you had told the mail function to do. If you use SMTP and view the original the email is actually sent from someone@example.com

    You can download SMTP class from:

    1. https://code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.smtp.php?r=170
    2. http://www.phpclasses.org/package/14-PHP-Sends-e-mail-messages-via-SMTP-protocol.html

提交回复
热议问题