简体   繁体   中英

Sending email using mail() function in PHP

I am sending email using mail() function from my CentOS server. I am able to send using anyone's name without any authentication. For example, I am able to send email using my email address (abc@gmail.com -- say), my friend's email address (xyz@gmail.com -- say) or any other email address (billgates@microsoft.com -- say).

When someone receives my email from PHP code, it looks exactly like it was sent from the email address that I wanted to send from. I am using this PHP class for sending emails.

My question: How to prevent an email to be automatically marked as spam by the email service provider of the receiver (Gmail, Hotmail, MSN, Yahoo etc.)?

As of now, I have only option for sending email using mail() function only. My authentication code is not working.

Note: I am not going to do any spamming. My web application going to send emails to users who are creating new accounts on my website. And hence, I don't want email from my server to be automatically marked as SPAM by their email service provider (Gmail, MSN, Hotmail, Yahoo etc). I don't want my email to go directly to their SPAM folder instead of their Inbox.

Checkout DomainKeysSPF (发件人策略框架)。

You should use the domain name of your website as E-mail address eg noreply@mydomain.com. Because some mail servers will do a dns lookup for the domain stated in your e-mail address or even a reverse dns lookup. Since gmail.com does not resolve to the IP of your webserver the e-mail may get marked as spam. There are many other factors for an e-mail to become spam. For example HTML formatted mails (especially when containing external images) are more likely to get marked as spam than plain text mails.

Also make sure to use proper Mail headers for your mail, they may also be validated by the remote mail server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM