Jaroslaw Rafa:
> Hello,
> as Gmail is often putting e-mails from me into recipients' Spam folder, and
> there seems to be no solution for this (I tried everything to no avail), I'm
> considering an idea of sending e-mail to Gmail users via Gmail server, with
> help of a Gmail account specially created for that purpose. (If that doesn't
> help then - I guess - nothing helps :( ).
> 
> I have a few questions regarding how to configure this in Postfix.
> 
> 1) It's obvious that Postfix has to authenticate to Google SMTP server to
> submit mail through it (with credentials of that specially-created Gmail
> account). However, I found in the Postfix docs that SMTP client
> authentication works only with Cyrus SASL module, not with Dovecot one. I
> have currently Dovecot SASL configured, as Dovecot is running as my IMAP
> server, and I don't want to change that. Is it possible to have both SASL
> modules (Cyrus and Dovecot) installed and working simultaneously? Or to
> have Cyrus module working with Dovecot IMAP server? Well, it is actually
> more a generic Linux question than Postfix-specific, but I hope someone here
> will be able to answer :)

The Dovecot authentication server has information about local users.
This may explain why there is no SASL client implementation for
Dovecot to log ino a remote server.

> 2) Assuming I have SMTP client authentication working, now I have to setup
> transport_maps (and smtp_sasl_password_maps) so that only mail to Gmail is
> sent through Gmail server. And here is some tricky part.
> 
> While putting the gmail.com domain explicitly as a key in transport(5) table
> is no problem, there is a multitude of companies that are using G Suite and
> have Gmail-hosted mail with their own domain, and I experience the same
> issue with them (ie. my mail being put to Spam by Gmail). So there's a need
> to check if the MX for a destination domain is within google.com or
> googlemail.com domain, and if yes, to send mail via Gmail server as well. 
> Is there any way to do it with transport_maps ?

There are two places where Postfix can do MX lookups for a remote
recipient:

- In the SMTP client.

- In the SMTP server (check_recipient_mx_access). 

You can use check_recipient_mx_access to return 'filter:gmail-submission',
and have a gmail-submission transport in master.cf that always sends
mail through the gmail submission server.

The example below uses 'filter', which would conflict with other
'filter' settings for spam blocking etc. If you would have that
conflict, you would need to set up a separate Postfix instances for
inbound and outbound mail, and apply the example below to the
outbound Postfix instance.

Disclaimers:

- It applies the filter to all recipients including those
  that aren't hosted at Google.

- untested example

/etc/postfix/main.cf:
    smtpd_recipient_restrictions = 
        check_recipient_mx_access hash:/etc/postfix/rcpt_access

/etc/postfix/rcpt_access:
    # Assumes parent_domain_matches_subdomains = ...smtpd_access_maps...
    googlemail.com      filter gmail-submission:smtp.gmail.com
    google.com          filter gmail-submission:smtp.gmail.com

/etc/postfix/master.cf:
    smtp      unix  -       -       n       -       -       smtp
        -o smtp_sasl_auth_enable=yes
        -o smtp_sasl_password_maps=whatever

If you don't have other 'filter' settings then you can implement
the above example in the Postfix instance that receives inbound
mail.

        Wietse

Reply via email to