Change IP of outgoing SMTP server and DKIM / SPF records

Change IP of outgoing SMTP server. Sometimes you need to have a number of different IPs so that it definitely divides on right your marketing communication with regular transaction emails. Because transactions email should arrive very well with right reputation should in no case these two mixed through 1 IP and thus communication should be divided IP. Or this method is also applicable if you want to replace an IP by any reason.

In this file you need to

vim /etc/postfix/sdd_transport_maps.regexp

define per domain or per email sender IP


/@vindazo$/ vindazo:

vim /etc/postfix/main.cf

Here you need to determine internal interfaces.

inet_interfaces = localhost, 188.40.155.250, 188.40.155.XXX, ezev..


Sometimes

smtp_bind_address = 188.40.155.223

Here you say which IP should send which domain or sender


vim /etc/postfix/master.cf


vindazo unix - - n - smtp

-o syslog_name=vindazo.be

-o smtp_helo_name=vindazo.be

-o smtp_bind_address=188.40.155.XXX



Don't forget to restart the service


service postfix restart


Also know that if you have changed an IP then you have to warm it up and if you immediately start sending more than 1000 your transmission will be blocked by providers like Microsoft.

So, you can view current que with command like.
 
mailq


and remove al emails from que with


postsuper -d ALL
 

DKIM

vim /etc/opendkim.conf 

Domain          *
KeyFile     /etc/mail/vindazo/default
Selector        mail 

 

There is public key. Use it in your DNS configuration

vim /etc/mail/vindazo/mail.txt 


Check DNS name

TXT mail._domainkey v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQK.... 

See example..  Wait enough time because you may encounter various weird error messages if your DNS is not changed / updated  ;

 

vim /etc/opendkim/TrustedHosts 

www.vindazo.nl
vindazo-alert.nl

...


total 20
drwxr-xr-x 2 root     root     4096 Jun  7 11:57 .
drwxr-xr-x 4 root     root     4096 Jun  7 11:43 ..
-rw------- 1 root     root      891 Jun  7 11:56 default
-rw------- 1 opendkim opendkim  887 Nov 12  2018 default.backup
-rw------- 1 root     root      313 Nov 12  2018 mail.txt
root@Ubuntu-1604-xenial-64-minimal /etc/mail/vindazo #


Change file owner ubuntu

drwxr-xr-x 2 root     root     4096 Jun  7 12:03 .
drwxr-xr-x 4 root     root     4096 Jun  7 11:43 ..
-rw------- 1 opendkim opendkim  887 Nov 12  2018 default
-rw------- 1 root     root      313 Nov 12  2018 mail.txt 

 


 service opendkim restart

 service postfix restart

 


Remark

We had a problem with daily alerts that were DKIM not valid.. But if we test sending via shell then the message was valid. That took a bit of time to figure out but apparently a message is limited in scope. This is Django bug..


In general, the email message is too long. If you change job.description to 100 or 150 words and slice text message to 1000 then DKIM will be PASS.

render_to_string("cyclusemail/cyclusemail.txt", context={"site":current_site, "cyclus":item})[:1000]



https://stackoverflow.com/questions/40433050/dkim-only-works-on-short-messages/40434211#40434211

 


Comments