There is nothing wrong with Postfix or PHPMailer! It's really not the reason that your emails are landing in spam.
These are one of the top open-source tools for generating and sending emails at scale. You might be thinking that the default email headers which Postfix or PHPMailer adds might be the reason for emails being landing in spam, but that's not the reason. There are other factors which trigger anti-spam engines to classify your emails as spam. ISPs and anti-spams are worried about three W's:
Who is sending?
What is being sent?
Whom it is being sent to?
Here are a couple of email-related configurations, which will help you to check, how closely your emails compile with various ISP and anti-spam policies:
1. Are you following the standard authentication protocols of sending emails?
- SPF: SPF stands for Sender Policy Framework. It is an authentication protocol which, when used allows senders to specify which IP addresses are authorized to send emails on behalf of a particular domain. To ensure that your customers and your brand are protected from phishing and spoofing attacks, you need to authenticate your email with an SPF record. Learn more on how implementing SPF can help prevent your emails from been categorized as spam.
- DKIM: DKIM is the acronym for DomainKeys Identified Mail. It is an authentication protocol used to validate sending domain names with email messages. DKIM protocol allows email senders to identify the domains that belong to them, thus protecting brand and reputation. This controls spoofing and phishing of your domain name i.e. other senders cannot send emails pretending to be coming from your domain. Learn more on how to setup DKIM on your server.
- DMARC: DMARC is a reporting protocol for email authentication. It stands for Domain-based Message Authentication, Reporting & Conformance. DMARC uses the Sender policy framework (SPF) and Domain Keys Identified Mail (DKIM) to check email authentication. Learn more on why this is so important for ensuring your emails to reach inbox.
- TLS Encryption: Transport Layer Security (TLS) is a protocol that implements privacy and data integrity within two communicating entities.TLS encryption is a cryptographic protocol that ensures network security over end-to-end communication. It is the most broadly deployed safety protocol used today by web browsers and other applications that need to privately transfer data over a network. It includes file transfers, VPN links, instant messaging, VOIP and sending messages over email. Learn more on how doing TLS encryption can help you prevent your emails from been flagged as spam.
2. What is your current sender reputation?
Sender reputation refers to both the reputation of your sender domain and the IP address (of your server) which is been used to send your emails. Read more on how to check your sender reputation.
3. What types of emails you are sending and what is the speed at which you are sending?
Speed Of Sending Emails
If you have set up Postfix for sending just bulk marketing emails and that too to a third party list of non-optin users, then your emails are bound to land in spam in the first go itself. But, if you are sending to an optin user base, then ideally it should not.
But, despite whether your email list consists of optin or non optin userbase, if your emails are landing in spam then throughput/speed of sending emails should be checked. You should not be sending too much in an hour or a day to any ISPs specially to the top ones like Gmail, Yahoo, Outlook.
Here is why?
Because you have not sent anything before to Gmail using this IP address, then for Gmail its like a new IP with neutral reputation. Now, how come this IP started sending so many emails on Day 1 of its sending, when there is no prior history of this IP being used as a mail server.
So, instead of sending too much on Day 1, sending gradually say 100 emails on Day1 and then 150, 200, 500, 1000 and so on. But, remember recipients of your email should open your emails and not report it as spam. Spam Complaints should not be above 0.01% of the number of emails which you sent.
If you follow such a strict warmup process with great user engagement, then this is where you will start building the reputation for you sending IP address.
Many a time, you might have also observed that your first test email with no real content, but just a few test lines also landed into spam. This has mostly to do with your sender reputation and authentication protocols which you are following and not the content.
Type of Emails
As discussed above, while controlling the speed of sending emails is important, but at the same time, it is very important to keep a watch on the number of positive engagements (Email Opens, Clicks, Replies and not Spam Complaints/Delete) which you are attracting on your emails.
You can attract positive engagement on your emails only if you are sending which is really an interest for the recipient. If you are using a new IP address then it is always recommended to start with sending good important emails like Signup Confirmation, Order Confirmation, Forgot Password, Notifications and Digest type of emails and not really the marketing emails.
4. Reverse DNS and PTR record are in place?
Reverse DNS and PTR records are really a tricky term and not very popularly being used among developers. But, these two play a very important role when it comes to email delivery. Not having these, can make your emails land in spam. You already know about DNS, which maps a domain name to an IP address- This process is actually known as "Forward DNS".
"Reverse DNS" is just the opposite of it, where DNS maps an IP address to a domain name. Both of these are DNS mapping just different in terms of how the lookups happen.Let's now try to understand why this is so important to have this in place. Assume you have a server setup on AWS and sending emails from example.com and using one of the AWS IP address 184.108.40.206 which resolves to some ec2-compute-1.aws.com.
Now, for Anti-spam engines, this looks like an unauthorized email sending. Where the IP which is being used to send emails doesn't resolve to example.com (who is the real sender). However, it is resolving to some other domain ec2-compute-1.aws.com.
How to create Reverse DNS and PTR records
PTR record is the one which helps you achieve what you want from reverse DNS. A PTR (pointer) record maps an IP address to the domain name. You can only create a PTR record if you own a dedicated IP address. If you own an IP address, then your IP address provider might have given you the control panel for configurations:
- Related to the assigned IP address, if not then you need to contact your IP address provided to create a PTR record for the IP address.
- Here is an example of how the PTR record will look like;
220.127.116.11.in-addr.arpa. 6230 IN PTR mymailserver.example.com.
Note: if above is the PTR record you have created, then make sure all your emails from Postfix or PHPMailer are going with Sender Envelope or Return-Path domain as mymailserver.example.com. Your From/Sender domain can be example.com or anything else also. But, the Return-Path domain should match with the one you have configured in the PTR record.
Mostly in case of VPS and dedicated servers, you get a dedicated IP address. But, if you are on shared hosting then it won't be possible to do reverse DNS setup by creating the PTR records. Here is a list of documentation on how to setup Reverse DNS which some of the popular DNS providers. Based on your DNS provider visit the below links to read the details:
While all of these are not limited but are the leading reasons for your emails to get delivered in the spam folder. Hope this information helped, stay tuned for more insights on handling spam.
In case you have any questions, please feel free to comment below.