What should be my MX records for postfix configuration like for mail forwarding?

13,264

Because your virtual maps are the hash type (as specified by the hash: in the config line) after creating the virtual file you need to create the map by running postmap /etc/postfix/virtual.

Judging by the errors in the logs, you also need to run postalias /etc/aliases because it's complaining that there is no aliases.db file.

There's a typo in your virtual_alias_domains config line. The first letter of the domain is a Q rather than a G.

virtual_alias_domains = qintegraconstruccion.com

If that exists in your actual config file and isn't just a typo in the question here, it needs fixing too.

Lastly, there appears to be one successful forwarded email in that log sample you provided. Message 1BC40432EF was successfully sent to Google. Google may well have discarded the email after accepting it but they did accept it.


General deliverablity will be important for you. Since you are not running Google Apps for Business, you have no way of whitelisting your IP address from within Google. So you will have to conform to all the normal best practices. If you get it all correct, Gmail should not reject your mail.

  • You don't currently have a reverse lookup on your IP address. You will have to ask DigitalOcean for this. It should be the same as the myhostname directive in your postfix config. I would recommend using contacto.gintegraconstruccion.com since it already points to the correct IP address.
  • You are not currently on SpamHaus's PBL. This is good, but lucky. Amazon EC2 addresses are on the PBL unless you ask Amazon to remove yours. Cloud providers (and residential providers) are likely to be on the PBL because their policy is that you should not be sending mail from that IP address.
  • You have no SPF record.
  • It's unlikely that you have a DKIM record.
  • You have no DMARC record. This one will help with understanding why some providers are rejecting your mail. If you configure your SPF or DKIM records incorrectly, the DMARC reports will let you know.
  • The From: address is an @gmail.com address. I don't know what your envelope-from address would look like but if it's also gmail.com then any host that supports SPF will reject your mail because your IP address is not in Gmail's SPF record. The envelope-from address is set by the smtp_helo_name line in your postfix config.
Share:
13,264

Related videos on Youtube

diegoaguilar
Author by

diegoaguilar

I'm a mexican backend web developer interested in performance and infrastructure development. I've been working with Node/express mainly for last 3 years doing API's design and implementation. Been pretty involved with MEAN apps too, and pretty involved with MongoDB in particular. I really can say I love express before frameworks. About languages, Right now I'm pretty involved with Javascript, with new ES6 and ES7 stuff. I've got experience with Java and Python too, can even work a bit in Android what I've liked. Would love to get to know Go, Elixir and these trending functional programming languages soon ;) Image processing and natural language processing are challenging topics for me, and I'd love to lead my career to high performance and availability aplications and stacks development. I rather do backend development but lately I've been trying React, which I enjoy. Apart from software development, I love Real Madrid and watching movies and series, of course music, and I also love food, like a lot.

Updated on September 18, 2022

Comments

  • diegoaguilar
    diegoaguilar over 1 year

    I have a Digital Ocean VPS, at which I installed postfix. I want to do mail forwarding.

    When I installed postfix I picked No configuration option. Later I set up the following:

    I created main.cf at /etc/postfix

    virtual_alias_domains = gintegraconstruccion.com
    virtual_alias_maps = hash:/etc/postfix/virtual
    

    Created virtual

    [email protected] [email protected]

    I restarted postfix then.

    At my DNS configuration (I got godaddy) I did:

    Created an A record:

    Host        Points to
    contacto    107.XX.XX.XX
    

    Created a MX record:

    Host        Points to
    @           contacto.gintegraconstruccion.com
    

    However I tried it and got any mail at my gmail inbox.

    The output of dig gintegraconstruccion.com is:

    ; <<>> DiG 9.8.1-P1 <<>> gintegraconstruccion.com mx
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34297
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;gintegraconstruccion.com.  IN  MX
    
    ;; ANSWER SECTION:
    gintegraconstruccion.com. 599   IN  MX  0 contacto.gintegraconstruccion.com.
    
    ;; Query time: 93 msec
    ;; SERVER: 8.8.4.4#53(8.8.4.4)
    ;; WHEN: Wed May 14 13:01:53 2014
    ;; MSG SIZE  rcvd: 67
    

    Just for the record, I'm currently hosting site with Openshift as I've not migrated it.

    Cheking at /etc/log/mail.log I found:

    May 14 11:52:51 localhost postfix/postfix-script[24478]: fatal: the Postfix mail system is not running
    May 14 12:02:05 localhost postfix/postfix-script[24600]: fatal: the Postfix mail system is not running
    May 14 12:02:27 localhost postfix/master[24724]: daemon started -- version 2.9.6, configuration /etc/postfix
    May 14 12:02:31 localhost postfix/master[24724]: reload -- version 2.9.6, configuration /etc/postfix
    May 14 13:06:07 localhost postfix/smtpd[24865]: error: open database /etc/aliases.db: No such file or directory
    May 14 13:06:07 localhost postfix/smtpd[24865]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
    May 14 13:06:07 localhost postfix/smtpd[24865]: connect from f.qw.se[109.74.194.71]
    May 14 13:06:13 localhost postfix/smtpd[24865]: disconnect from f.qw.se[109.74.194.71]
    May 14 13:06:44 localhost postfix/smtpd[24865]: connect from f.qw.se[109.74.194.71]
    May 14 13:07:07 localhost postfix/smtpd[24865]: 5F052432EF: client=f.qw.se[109.74.194.71]
    May 14 13:07:15 localhost postfix/smtpd[24865]: disconnect from f.qw.se[109.74.194.71]
    May 14 13:10:36 localhost postfix/anvil[24867]: statistics: max connection rate 2/60s for (smtp:109.74.194.71) at May 14 13:06:44
    May 14 13:10:36 localhost postfix/anvil[24867]: statistics: max connection count 1 for (smtp:109.74.194.71) at May 14 13:06:07
    May 14 13:10:36 localhost postfix/anvil[24867]: statistics: max cache size 1 at May 14 13:06:07
    May 14 13:14:20 localhost postfix/master[24724]: reload -- version 2.9.6, configuration /etc/postfix
    May 14 13:18:29 localhost postfix/master[24724]: reload -- version 2.9.6, configuration /etc/postfix
    May 14 13:21:04 localhost postfix/smtpd[24982]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
    May 14 13:21:04 localhost postfix/smtpd[24982]: connect from mail-wi0-f175.google.com[209.85.212.175]
    May 14 13:21:05 localhost postfix/smtpd[24982]: 1BC40432EF: client=mail-wi0-f175.google.com[209.85.212.175]
    May 14 13:21:05 localhost postfix/cleanup[24987]: 1BC40432EF: message-id=<[email protected]$
    May 14 13:21:05 localhost postfix/qmgr[24976]: 1BC40432EF: from=<[email protected]>, size=2670, nrcpt=1 (queue active)
    May 14 13:21:05 localhost postfix/smtpd[24982]: disconnect from mail-wi0-f175.google.com[209.85.212.175]
    May 14 13:21:05 localhost postfix/smtp[24988]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400e:c01::1a]:25: Network is unreachable
    May 14 13:21:06 localhost postfix/smtp[24988]: 1BC40432EF: to=<[email protected]>, orig_to=<[email protected]$
    May 14 13:21:06 localhost postfix/qmgr[24976]: 1BC40432EF: removed
    

    Last lines of log (after mail sent from a hotmail worked):

    May 14 13:52:19 localhost postfix/smtpd[25133]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
    May 14 13:52:19 localhost postfix/smtpd[25133]: connect from col0-omc1-s18.col0.hotmail.com[65.55.34.28]
    May 14 13:52:20 localhost postfix/smtpd[25133]: 22ED0432EF: client=col0-omc1-s18.col0.hotmail.com[65.55.34.28]
    May 14 13:52:20 localhost postfix/cleanup[25137]: 22ED0432EF: message-id=<[email protected]>
    May 14 13:52:20 localhost postfix/qmgr[25091]: 22ED0432EF: from=<[email protected]>, size=1528, nrcpt=1 (queue active)
    May 14 13:52:20 localhost postfix/smtpd[25133]: disconnect from col0-omc1-s18.col0.hotmail.com[65.55.34.28]
    May 14 13:52:22 localhost postfix/smtp[25138]: 22ED0432EF: to=<[email protected]>, orig_to=<[email protected]>$
    May 14 13:52:22 localhost postfix/qmgr[25091]: 22ED0432EF: removed
    
    • Håkan Lindqvist
      Håkan Lindqvist about 10 years
      It doesn't look like a problem with the MX records. Did you check your postfix logs?
    • diegoaguilar
      diegoaguilar about 10 years
      @HåkanLindqvist check my edits
  • diegoaguilar
    diegoaguilar about 10 years
    It was a typo in the question, at the file I got it correct, with g. I did run postmap but didn't run postalias. I tried with a hotmail mail and it mailed instantly an older mail after postmap and reloading, but not consequent sent mails. I changed the forwarding mail to an @icloud and it's not sending anything, not even in logs ... Thanks in advance
  • diegoaguilar
    diegoaguilar about 10 years
    Well I sent from a hotmail account and it was forwarded instantly. I will update now my post with some information about a mail which seems to be on queue. Thanks
  • diegoaguilar
    diegoaguilar about 10 years
    Can you extend a lil bit more about the points you marked I should follow? I'm a newbie about mailing and servers administration.
  • Miguel
    Miguel over 7 years
    One question, even if i use an external email server like sendgrind, do the spam filters still probe for the domain and find that domain is not the same as the sending one, wont that cause troubles?