1

I'm totally new to "Email Systems" and it's concepts. I just use a simple email sending codes via PHP, like:

mail("recipient@gmail.com","my header","my body");

I understand this is going through postfix because when i stop the postfix like:

service postfix stop

Then the emails wont go out already. Then when i start it back again:

service postfix start

Then the emails are going out. (As i mentioned, i do not understand anything about Email Systems, but this confirms i am using postfix.)

So the question comes:

  • Why these emails are going into Gmail's SPAM box?
  • What do i need to do?

Please kindly tell me any (every) thing i need to do, to send email(s) properly from my server.

p.s, My server is a CentOS 6.4 box on DigitalOcean, with a Public IP.

1

Most likely your IP is spam-blacklisted, some service providers are notorious for having their subnets blacklisted. To fix this you need to request removal of any IP ranges you're concern from any blacklists they may be in, they will do so after some verifications. Also, you need to authenticate your emails using different technologies like DomainKeys Identified Mail (DKIM), SPF and Sender ID. This is a full time job.

The solution that worked for me is setting Postfix as a proxy. Basically, you make Postfix act like a client that sends emails through a reputable relay service, in my case gmail. You will need to add the following to Postfix configuration file, main.cf :

smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_dependent_relayhosts
relayhost = [smtp.gmail.com]:587
smtp_use_tls=yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

You will also need to create the map files and hash them:

/etc/postfix/sasl_passwd:

# per-sender authentication
account1[@]gmail.com account1[@]gmail.com:passwd1
account2[@]gmail.com account2[@]gmail.com:passwd2
# default relayhost
[smtp.gmail.com]:587 default_account[@]gmail.com:default_passwd

/etc/postfix/sender_dependent_relayhosts:

account1[@]gmail.com [smtp.gmail.com]:587
account2[@]gmail.com [smtp.gmail.com]:587

Hash the maps files:

postmap sasl_passwd sender_relay

A reputable relay service ensures your emails are not classified as spam. Good luck!

4
  • Hi thanks for the kind answer, but i think you've misunderstood my issue. I'm NOT using Gmail as my relay/smtp. I'm just sending "To Gmail" directly from my Postfix. So at the destination (Gmail Recipient) side, Gmail marked our emails as SPAM. And it shows: "From: "Apache@example.com". – 夏期劇場 Jul 9 '15 at 3:27
  • 1
    Read the first paragraph of my answer. DigitalOcean is known for having some of its subnet ranges flagged for spamming, being so cheap anyone can spam around on the pennies. My suggestion is to get a SMTP relay service. – angelcool.net Jul 9 '15 at 4:22
  • Ok thanks. Using the SMTP Relay is another story. If I use relays, like 'Gmail' for example, I will be then capped by their limits, rite? Which means, my own Server can send far higher amount as I need, compared to Relay Services. Am I correct to say that please? – 夏期劇場 Jul 9 '15 at 6:10
  • 1
    Yes, you will be capped by their limits. It all comes down to what exactly your needs are. Gmail limits : stackoverflow.com/questions/18361233/gmail-sending-limits You can look around for higher limits , at an extra cost of course. The ultimate solution is to run your own SMPT servers, but as I said that's a full time job, it would require dedicated infrastructure too. – angelcool.net Jul 9 '15 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.