Configuring Postfix with Yandex.ru relay in Ubuntu 16.04

Today I read that Postfix can be better than sendmail and found a great Russian article on how to configure Postfix to work with Yandex.ru relay (Yandex.ru is some kind of Russian Google). The only notice I would give is that in a Docker container I need also install rsyslog, otherwise /var/log/mail.log file is not created:

apt install rsyslog

After doing all the steps described in this Russian manual I was able to send email to Yandex.ru and GMail accounts, but GMail landed all the emails to its spam folder. My first idea was that it is because I did not configure ‘from address’ correctly, so I had the following in /var/log/mail.log, and also there was a message ‘Cannot assign requested address‘:

Oct 27 11:36:19 0675c97b78aa postfix/pickup[1210]: 8C7ECE5B72: uid=0 from=<root>
Oct 27 11:36:19 0675c97b78aa postfix/cleanup[10786]: 8C7ECE5B72: message-id=<20171027113619.8C7ECE5B72@0675c97b78aa.localdomain>
Oct 27 11:36:19 0675c97b78aa postfix/qmgr[1211]: 8C7ECE5B72: from=<root@0675c97b78aa.localdomain>, size=405, nrcpt=2 (queue active)
Oct 27 11:36:19 0675c97b78aa postfix/smtp[10788]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c09::1b]:25: Cannot assign requested address
...

And email header in GMail inbox contained ‘localdomain address’:

Delivered-To: XXX@gmail.com
Received: by 10.140.31.202 with SMTP id f68csp695216qgf;
        Fri, 27 Oct 2017 05:36:19 -0700 (PDT)
X-Google-Smtp-Source: ABhQp+SPxJH1fvDe5DxZGgsIPrnRQ5rdKvPFwmtp/1PyMOrXhWHACL9pJuXT5zkeg6VMVO3aZjjo
X-Received: by 10.28.29.205 with SMTP id d196mr289662wmd.106.1509107779712;
        Fri, 27 Oct 2017 05:36:19 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509107779; cv=none;
        d=google.com; s=arc-20160816;
        b=NnCuAUnD+CiRi6XultIHywjeAKILSesvG/eDeYyPPaiOW9lTTKv4Swjjthg7JkGPZV
         qfIGkgcXJqWwGuq5ASEHBcRze7dNIebeXzmf9ilUi5Go0cgBEieAaoM6KfCSswiuIvrl
         rzACAMRx7iL2RKay/Mi1cdmLHEuycUviG4VjXgXnDwrhEXKuRY1nCq/oW89jb5wzj6P9
         adLk/oPjcjtkWVvudP3BGGMxGqo/FyN3PcipEutle0yuMdOWcD760MYE8jc1T9rR/WvD
         jKDLrBJDRn9glW9H+b+Tt6Lx/bMlmJbjyO+n+dw968mFv5KiA9wpvWjksUVzpW9tmjOm
         pu6A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=date:message-id:from:to:subject:arc-authentication-results;
        bh=ajrpRrolctsK5lgNWSV5xRWP0kftGtNg0KDcEqeY694=;
        b=PQlFhKmnf2/vZR4Vp9PeZg/i9yLth3IfK7k6IusYrG0FqpDruyJi4dsJntm7nAunVj
         yJYeaiu/OOm2ENSIKJbgiFpi2kGV4hoDIzJRmawIY5xFmELo7HJU0F8jBcwB6t22Dpu2
         itNlA/BNY+wp/rYrXDx1Yz36lNGgaxLgIl7h6FlvbDmT0itqBaOfadUzkSWTW/5VGxjc
         J5edh6HBNQ45Y9y1l0LSTYKl8NPeisASn8IEh00CX566M4+/YkKy9NBG0pFB/jh6CY1z
         rZyXa3lV0u9UzdcqSZemwdWTbiWGPHFhkIgNZha3cb4TJsjHvaPYfrrYkiq2TPrbq1/E
         FcNA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 139.162.243.103 is neither permitted nor denied by best guess record for domain of root@0675c97b78aa.localdomain) smtp.mailfrom=root@0675c97b78aa.localdomain;
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru
Return-Path: <root@0675c97b78aa.localdomain>
Received: from 0675c97b78aa.localdomain (li1528-103.members.linode.com. [139.162.243.103])
        by mx.google.com with ESMTP id r13si5494659wrg.374.2017.10.27.05.36.19
        for <XXX@gmail.com>;
        Fri, 27 Oct 2017 05:36:19 -0700 (PDT)
Received-SPF: neutral (google.com: 139.162.243.103 is neither permitted nor denied by best guess record for domain of root@0675c97b78aa.localdomain) client-ip=139.162.243.103;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 139.162.243.103 is neither permitted nor denied by best guess record for domain of root@0675c97b78aa.localdomain) smtp.mailfrom=root@0675c97b78aa.localdomain;
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru
Received: by 0675c97b78aa.localdomain (Postfix, from userid 0) id 5F04FE5B72; Fri, 27 Oct 2017 12:36:19 +0000 (UTC)
Subject: test mail to Some Address!
To: Me <XXX@gmail.com>
From: Vasya <XXX@yandex.ru>
Message-Id: <20171027123619.5F04FE5B72@0675c97b78aa.localdomain>
Date: Fri, 27 Oct 2017 12:36:19 +0000 (UTC)

first line of my message

In Yandex.ru inbox:

Received: from mxfront12g.mail.yandex.net ([127.0.0.1])
	by mxfront12g.mail.yandex.net with LMTP id g8Rq5bAq;
	Fri, 27 Oct 2017 14:32:30 +0300
Received: from li1528-103.members.linode.com (li1528-103.members.linode.com [139.162.243.103])
	by mxfront12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id IIHHej4nOp-WTZOkxWK;
	Fri, 27 Oct 2017 14:32:29 +0300
Return-Path: root@0675c97b78aa.localdomain
X-Yandex-Front: mxfront12g.mail.yandex.net
X-Yandex-TimeMark: 1509103949
X-Yandex-Spam: 1
Received: by 0675c97b78aa.localdomain (Postfix, from userid 0)
	id D354BE5B72; Fri, 27 Oct 2017 11:32:28 +0000 (UTC)
To: XXX@yandex.ru
Subject: My subject 1
X-PHP-Originating-Script: 1000:send.php
From: XXX@gmail.com
CC: XXX@yandex.ru
Message-Id: <20171027113228.D354BE5B72@0675c97b78aa.localdomain>
Date: Fri, 27 Oct 2017 11:32:28 +0000 (UTC)
X-Yandex-Forward: 83938fd9893ad788cf792ddfa68a0e0a
X-Yandex-Forward: a8c50329ae5e4eaa440a48a9e2df76be

First line of text
Second line of text

I tried the following links, but with no success yet:

  1. Postfix masquerading or changing outgoing SMTP email or mail address
  2. How to change default root@ email address linux / postfix / centos?
  3. Generic mapping for outgoing SMTP mail
  4. myhostname in /etc/postfix/main.cf
  5. How to Setup WordPress with LAMP + Postfix as Send-Only Mail Notifications on VPS Server
  6. How To Install and Configure Postfix as a Send-Only SMTP Server on Ubuntu 14.04
  7. Enabling SASL authentication in the Postfix SMTP/LMTP client

So my battle with Google spam filter is still not over.

To remove sendmail I did this:

apt-get remove --auto-remove sendmail*
apt-get purge --auto-remove sendmail*

Leave a Reply

Your email address will not be published. Required fields are marked *