perfectowebWeb design & programming studio
Blog Code

Sent letter get into the spam folder

Among the most widespread issues about the webmaster’s work the terminal mail delivery can be mentioned specifically.
This article is about some tips on proper server settings, script installations and such, which helps avoiding cases when some important corporative letters fall into the SPAM folder. By following these instructions, you are going to minimize the probability of your letters getting into the folder of unwanted junk mail.

Correct headers

First off, while sending any letter using scripts, avoid leaving the title field empty. If you work with PHP it’s highly not recommended sending «bare» messages with no titles such as mail("", "My Subject", "My Message");
These are the letters most probably to fall into the SPAM folder.
A quality letter has to contain at least the following features:
  • From: Perfecto Web < >
  • Reply-To: Perfecto Web < >
  • X-Mailer: Php_libMail_v_1.5
  • Content-Type: text/html; charset=utf-8
  • Mime-Version: 1.0
Also, the mail has to have not only the sender’s address, but their name and the name of the company as well. Don’t forget about the Reply-to address feature. It’s vital also to point out the encoding type (Content-Type) and the program (X-Mailer) the message was sent through.

NOTE: IP address of the mail sending program should be identical to the domain’s IP address.
To create appropriate titles you may use some completely prepared libraries: PHPMailer, Swift Mailer, libmail.

Sending through SMTP

SMTP is a protocol used to send email.
Thus protocol is responsible for the data transcription between client → server, server → server and server → client.
To start with, you have to create an e-mail box at your server. Say, Thereafter, you set a PHP script onto authentication via SMTP.
Normally, your SMTP settings are these:
  • Host: mail.your_domain or smtp.your_domain
  • Port: 25 (alternate port 25025)
  • Username:
  • Password: your_password
Mail transfer through SMTP is the most reliable and safe.
Refer to your hosting-provider to get more info on your SMTP settings.

The transcription entry PTR

DNS is used to transcribe the domain name into IP address, but it can also perform the opposite process.
There is a special domain, the records of which are used to transcribe IP addresses into symbolic names. Say, while requesting the, DNS servers will redirect you to the following IP address: However, dealing with PTR you have an reverse converting, and requesting for the IP DNS servers will get you to the symbolic name: -

Postal services recommend specifying PTR records identically with the mail sending domain.
If you won’t be able to find the PTR settings in the control panel, clarify their location with your hosting provider.


If you possess VPS, VDS, or, for whatever reason manage your domain’s DNS by yourself, we recommend you to consider choosing some correct SPF-records for your domain. SPF entry must contain IP address of the server, which holds your website.
If your DNS records lacks entry about the SPF, insert the following:
Value:v=spf1 a mx ip4: ~all
Note that in the host field you have to put a period after domain. Accordingly, instead of just put your domain’s IP address. We recommend to specify separate SPF entry for each domain.

SPF record is necessary for decreasing the probability of the messages sent from your domain falling into receivers’ spam folder.
SPF settings aren’t vital, but they are helpful in increasing the chances for your messages to be delivered properly.

DKIM setup

SPF & DKIM are somewhat identical technologies, as both of them are designed to confirm the validity of the sender.
DKIM - DomainKeys Identified Mail meaning, method of the E-mail authentication.
DomainKeys Identified Mail (DKIM) technology unites several existing anti-fishing and anti-spam methods aimed to improving the email’s qualification level, and legit email identification. Instead of the traditional IP address, in order to define the sender, DKIM adds a digital status into it, connected with the organizational domain name. This signature is automatically checked on at the receiver’s side, after which, so called «white lists» or «black lists» are used to maintain the sender’s reputation.
The DomainKeys technologies use domain names for the senders’ authentication. DomainKeys utilizes an existing domain names system (DNS) to transfer the open encrypting (encoding) keys.
Source: Wikipedia
Off we go. To start with, you need to create a couple of keys: public and private. You can do that many ways. For instance, you can use OpenSSL, but we will go specific on the Moving to the DKIM Wizard section, in the fields provided you enter the domain name and chose the key size. As you have only one postal server, specify «dkim» in the selector. As of today, Gmail recommends the 1024bite key, so just select it and click «Create the Key».
The next screen will show you both public, as well as a step by step guidance on the DKIM alignment. Add the entry into DNS settings.
It must look approximately like the following:
Value:v=DKIM1; k=rsa; s=email; p=MIGfMA0GCSqGSIb4DQEBAQUAA4GNADCBiQKBgQDgS1AZb9K924hWLVyodfyaQShVyLY0HceJk9JWd+bA3g78a4cEilzZUFu4hBFSX1QGWrloDN/omwz89IfOxl1eUFtqRXiQBaKgBvwIH/qGkKoiGikYj+4ETbdBdHhjDLoNK8PH0YAmNZ2brllGPYEC60QYjf8LG6+KRff7n98RKQIDAQAB
As you see, «dkim» - is our selector, then comes _domainkey, and then after that comes your domain. (don’t forget to put the period in the end).
After the «p=» combination our public key must follow directly.

Private key
Initially, we need to know whether the postal service supports digital subscription of DKIM. Virtually any of the new postal server versions does support it. Otherwise, you can apply to your system administrator or to a specialist, in order to install the mail service with the DKIM support.
We save the previously obtained private key with the extension *.pem. In our case, we came out with «»
You can save the key in /etc/pmta for Linux systems, or in C:/pmta for Windows.

Additional factors

There are many factors able to compromise the letter sender’s reputation, as well as the reputation of the mailbox in general.
  • We wouldn’t recommend to send messages with iframe !important
  • We wouldn’t recommend to send messages from JavaScript !important
  • We wouldn’t recommend to send messages with applets and Flash!important
  • Always put the alt description for all images in the mail
  • Delete all broken links from the website you’re sending the letter on behalf
  • Do your best for the letter to show correctly from all possible devices
  • Do not send emails to people who have not subscribed to the newsletter !important
  • Always insert an unsubscribe link, if doing newsletter !important
  • Do not write the entire title in capitals !important
  • Use List-Unsubscribe header for transmission links for quick unsubscribe
  • Any message must be formatted in accordance with the standards RFC 5322 and HTML

Few additional tips


Like this? Subscribe!

Sent letter get into the spam folder
Share this article
Subscribe and get new posts of web technologies
Comments: 0
Views: 2,851
Published: 12 Jun 2015

Choose language