I can not competently send mail in conjunction:

  • PHP mail () function
  • exim4
  • ubuntu 14.04

A piece of code on php

mail( $to, $subject, $body, $headers, '-f' . $from ); // В $headers есть заголовки: From, Reply-To, Return-Path 

sendmail_path: /urs/sbin/sendmail -i -t (all by default) is registered in php.ini .

Exim4 works and sends mail.

DKIM, SPF is also ok.

Problem:

I send mail to the mail-tester.com mail-tester.com and it tells me that I do not have rDNS records. As a result, all my letters fly to spam.

VPS purchased in one office (reg.ru), domain in another (GoDaddy). A domain is bound to Yandex.Mail for a domain. Those. MX records indicate:

MX priority 10, @, is sent to mx.yandex.net

Mail, works, accepts.

The problem is only in rDNS or RTC.

Output of several commands: nslookup МОЙ_VPS_IP

 Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: 666.666.666.666.in-addr.arpa name = mysite.com. Authoritative answers can be found from: 

Online rDNS or RTC verification services say that I’m fine and show my domain, which is bound to ip.

PS If you need output any more commands, write.

Yandex only accepts mail (without their SMTP). VPS use to send.

Closed due to the fact that it was off topic by aleksandr barakin , cheops , user207618, HamSter , tutankhamun 12 Oct '16 at 6:27 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Maybe in my exim4 configs what should I add? - mr.pob
  • Domain where delegated? Why don't you use smtp? - Andrew Hobbit
  • Read about PHPMailer, configure smtp yandex relay - Vyacheslav Potseluyko
  • four
    This question should be closed, because there is no exchange of freelancers. - aleksandr barakin pm
  • @ alexander-barakin I beg you without tediousness. This is just such a thank you - mr.pob

2 answers 2

I will assume that you have configured DKIM, SPF records.

rDNS - This is the conversion of your IP address to a domain, if the IP address from which the letter was sent does not match the domain name, your letter will go to spam. So, Your domain has a record on the DNS servers And an entry that links your domain with the IP address of the server where your site is located. And the PTR record does the opposite - it associates the IP address with the domain.

Basically, it is necessary when sending letters on behalf of your domain. Most mail servers, before making a decision - put the letter in the Inbox or reject it as SPAM, check the PTR record against the IP address of the server from which this letter came. If this record is present, and it coincides with the name of the domain on whose behalf the letter was received, this will be one of the facts for making a positive decision (that this letter is not SPAM).

Because A PTR record is a reverse record that associates an IP address with a domain, then the owner of the IP address assigned to the server where your site is located must register it. In other words, you need to contact your hosting and ask to register a PTR record for the IP address . Domain registrar will not help you here (unless of course you are using his hosting).

It is worth registering a PTR record if you use a VPS or a dedicated server. If you use virtual hosting, then, as a rule, this entry is already there and indicates the name of the host server.

  • Yes, it's easier according to my instructions to configure and not to steam, because it uses mail for a domain based on yandex. And mind you, he set up Exim4, and tries to send mail from sendmail - avparfiriev
  • @avparfiriev Well, in general, you can send via SMTP, I personally use services that do this, such as Mailgun, to send emails, a very convenient API and nothing to configure except for a couple of records in the DNS, but he tries to deliver and checks the delivery. - Firepro
  • Well, here I’m talking about if it is fun for a person to invent the “Wheel” - avparfiriev
  • Hi, thanks, I will check now. Unsubscribe - mr.pob
  • Regarding the price tag - this is our "Thank you", ok? - mr.pob

Installing and configuring exim4

 Apt-get install exim4 

Settings for yandex.ru

Edit file

 nano /etc/exim4/update-exim4.conf.conf 

Add to file

 dc_eximconfig_configtype='smarthost' dc_other_hostnames='server' dc_smarthost='smtp.yandex.ru::587' 

Account Information

Edit file

 nano /etc/exim4/passwd.client 

add to file

 smtp.yandex.ru:username@yandex.ru:password 

Mapping of accounts and email-boxes

Edit file

 nano /etc/email-addresses 

Add / edit in file

 root: username@yandex.ru www-data: username@yandex.ru 

(Depending on the user under which it all rises, you must add your own)

Reboot the mail server

 sudo /etc/init.d/exim4 restart 

When this line is added to the crontab, after a reboot, a letter from the root user should come to mail@yandex.ru, that the server is restarted

 @reboot root sleep 60 && echo "Server reboot" | mail -s "server reboot" mail@yandex.ru 

If the letter came, then EXIM4 is set up correctly, then go on sending the message from php (everything is simple)

you can check out php like this:

 # cat testmail.php <?php mail('komu@mail.ru', 'тема письма', 'тело письма', 'From: ot.kogo@mail.ru'); ?> # php testmail.php 

In the "from whom", you must specify the user name (see the mapping of user names and email addresses)

  • Thanks, we’ll check now) - mr.pob
  • I'm not going to send via SMTP Yandex. Yandex is used only to receive mail. And I want to send letters through my VPS - mr.pob
  • And what is the difference if you still cling to the domain to pdd? - avparfiriev