sumit
sumit

Reputation: 11257

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 ([email protected] -- say), my friend's email address ([email protected] -- say) or any other email address ([email protected] -- 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.

Upvotes: 0

Views: 965

Answers (1)

Sbhklr
Sbhklr

Reputation: 2703

You should use the domain name of your website as E-mail address e.g. [email protected]. 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.

Upvotes: 1

Related Questions