Search code examples
emailsendmailgitlabpostfix-mtadovecot

Gitlab can't deliver email to Gmail Accounts


Problem

I have a Gitlab Omnibus edition installed on a DigitalOcean server. I find that when I create a new user account with a gmail ID, they never receive any email from Gitlab.

Poking through the mail.log file:

Jun  2 00:02:34 hostname postfix/pickup[13969]: D5FB82001C: uid=999 from=
Jun  2 00:02:34 hostname postfix/cleanup[18636]: D5FB82001C: message-id=
Jun  2 00:02:34 hostname postfix/qmgr[14920]: D5FB82001C: from=, size=5478, nrcpt=1 (queue active)
Jun  2 00:02:34 hostname postfix/smtp[18640]: connect to gmail-smtp-in.l.google.com[2404:6800:4003:c01::1a]:25: Network is unreachable
Jun  2 00:02:37 hostname postfix/smtp[18640]: D5FB82001C: to=, relay=gmail-smtp-in.l.google.com[74.125.200.26]:25, delay=2.2, delays=0.01/0.01/0.86/1.3, dsn=2.0.0, status=sent (250 2.0.0 OK 1433217891 j15si24377385pdk.208 - gsmtp)
Jun  2 00:02:37 hostname postfix/qmgr[14920]: D5FB82001C: removed

The relevant error seems to be:

connect to gmail-smtp-in.l.google.com[2404:6800:4003:c01::1a]:25: Network is unreachable

Which is strange, because I can send mail to gmail just fine via the command line.

Mail Server

My mail is setup on this server using postfix/dovecot/Squirrelmail. I'm afraid I don't understand too much about how this works, I pretty much just followed a bunch of tutorials to duct-tape it together, and haven't quite understood it yet.

Stuff that works

I've verified that the following two scenarios work:

  1. Send mail to gmail ID from command line works fine:

echo -e "Hello there" | mail -s "Test Email" "[email protected]"

Mail.log entries for this action:

Jun  2 00:23:46 hostname postfix/pickup[13969]: 853432001C: uid=1000 from=<vidur@hostname>
Jun  2 00:23:46 hostname postfix/cleanup[23752]: 853432001C: message-id=<[email protected]>
Jun  2 00:23:46 hostname postfix/qmgr[14920]: 853432001C: from=<vidur@hostname>, size=356, nrcpt=1 (queue active)
Jun  2 00:23:48 hostname postfix/smtp[23754]: 853432001C: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.200.27]:25, delay=1.7, delays=0.01/0/0.85/0.88, dsn=2.0.0, status=sent (250 2.0.0 OK 1433219162 fw3si24157505pbb.133 - gsmtp)
Jun  2 00:23:48 hostname postfix/qmgr[14920]: 853432001C: removed
  1. Send mail via Gitlab to random other domain - tested with Guerrilla Mail
Jun  2 00:31:20 hostname postfix/pickup[24015]: B66B92001C: uid=999 from=
Jun  2 00:31:20 hostname postfix/cleanup[24228]: B66B92001C: message-id=
Jun  2 00:31:20 hostname postfix/qmgr[14920]: B66B92001C: from=, size=5813, nrcpt=1 (queue active)
Jun  2 00:31:22 hostname postfix/smtp[24232]: B66B92001C: to=, relay=mail.sharklasers.com[198.143.169.10]:25, delay=1.7, delays=0.02/0/0.65/1.1, dsn=2.0.0, status=sent (250 OK : queued as a99f431dc4f7f2b50ad3980311a1d4a6)
Jun  2 00:31:22 hostname postfix/qmgr[14920]: B66B92001C: removed

I'm open to any ideas and suggestions. Do let me know if I can provide more information to help debug this problem. Thanks.


Solution

  • I almost feel stupid answering this, but I figured out my problem. Going to leave this here for posterity.

    1.

    I forgot to check the spam folder on the gmail account(s) in question. Gitlab confirmation/welcome emails seem to get picked up by most spam filters. Gitlab was correctly sending the email after all.

    Source

    2.

    I fixed the log error I reported by following this post and forcing my postfix to only use the IPv4 protocol. Not exactly sure what the side-effects of that change are, so I would not recommend it.

    It looks like Gitlab first tries to reach the gmail server over IPv6, and then falls back to IPv4. So that error in the log file can be safely dismissed I guess.