Loading ...
Sorry, an error occurred while loading the content.

Re: Say to Postfix which email need to be delivered locally based on the full email address and not just based on the local domain

Expand Messages
  • Noel Jones
    ... Please don t top post. Don t define gmail.com as a local domain!!!! Use virtual_alias_maps to direct user@gmail.com to a local address *instead of*
    Message 1 of 12 , Feb 1 11:13 AM
    • 0 Attachment
      On 2/1/2010 12:55 PM, Michele Carandente wrote:
      > Hi Noel.
      > Thanks for the reply.
      > The problem is not when I receive emails(because I'll fetch it with a
      > perl script), but when I've to send email(relay to smtp.gmail.com) from
      > gmail.
      >
      > Any suggestions?



      Please don't top post.

      Don't define gmail.com as a local domain!!!!
      Use virtual_alias_maps to direct user@... to a local
      address *instead of* defining gmail.com as local.

      If that doesn't help, then your problem is unclear. Please
      provide 'postconf -n' output and logging of the problem, along
      with a description of what you expect to happen that doesn't.
      http://www.postfix.org/DEBUG_README.html#mail


      -- Noel Jones
    • Michele Carandente
      Hi Noel, I ll explain better my problem: I ve this mailserver under a slow dial-up connection. To fetch email from the main mailserver I use some Perl scripts,
      Message 2 of 12 , Feb 2 1:57 AM
      • 0 Attachment
        Hi Noel,
        I'll explain better my problem:
        I've this mailserver under a slow dial-up connection.
        To fetch email from the main mailserver I use some Perl scripts, and
        they are working fine.
        I use postfix to queue the emails that needs to be send and then with
        the command "postqueue -i" I'll send the emails that I want(they will
        be relayed with smtp to the correspondent smtp server).

        In this mailserver I'll have most of the emails with a @...,
        but also few emails with @... or @...
        So if I add in mail_users the email user@... and so in
        mail_domains the gmail.com, everytime that from this mailserver I'll
        send an email to any @... email, postfix think that it's an
        internal email and try to delivery it as virtual(Recipient address
        rejected: User unknown in virtual mailbox table).

        To say to postfix which smtp server is related with the email, I've
        used sender_dependent_relayhost_maps.
        So the only issue that I've is just how to say to postfix which email
        is an internal one, based on the full email address and not based on
        just the domain.

        So I think that the alias in not helping me (but if I'm wrong please
        let me know :) ).

        Anyway, this is the output of postconf -n:
        alias_database = hash:/etc/aliases
        alias_maps = hash:/etc/aliases
        append_dot_mydomain = no
        biff = no
        broken_sasl_auth_clients = yes
        config_directory = /etc/postfix
        default_transport = hold
        defer_transports = hold
        html_directory = /usr/share/doc/postfix/html
        inet_interfaces = all
        inet_protocols = ipv4
        mailbox_size_limit = 0
        message_size_limit = 30720000
        mydestination = localhost, localhost.localdomain
        myhostname = hostname
        mynetworks = 127.0.0.0/8
        myorigin = /etc/mailname
        proxy_read_maps = $local_recipient_maps $mydestination
        $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps
        $virtual_mailbox_domains $relay_recipient_maps $relay_domains
        $canonical_maps $sender_canonical_maps $recipient_canonical_maps
        $relocated_maps $transport_maps $mynetworks
        $virtual_mailbox_limit_maps
        readme_directory = /usr/share/doc/postfix
        recipient_delimiter = +
        relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
        relay_recipient_maps = hash:/etc/postfix/relay_recipient
        relay_transport = virtual
        relayhost =
        sender_dependent_relayhost_maps = hash:/etc/postfix/bysenderrelay
        smtp_sasl_auth_enable = yes
        smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
        smtp_sasl_security_options = noanonymous
        smtp_sasl_tls_security_options = $smtp_sasl_security_options
        smtp_sasl_tls_verified_security_options = $smtp_sasl_security_options
        smtp_sasl_type = cyrus
        smtp_tls_CAfile = /etc/postfix/cacert.pem
        smtp_tls_cert_file = /etc/postfix/smtpd.cert
        smtp_tls_key_file = /etc/postfix/smtpd.key
        smtp_tls_loglevel = 2
        smtp_tls_scert_verifydepth = 5
        smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
        smtp_use_tls = yes
        smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
        smtpd_recipient_restrictions = permit_mynetworks,
        permit_sasl_authenticated, permit_auth_destination,
        reject_unauth_destination
        smtpd_sasl_auth_enable = yes
        smtpd_sasl_authenticated_header = yes
        smtpd_tls_CAfile = /etc/postfix/cacert.pem
        smtpd_tls_ask_ccert = yes
        smtpd_tls_auth_only = no
        smtpd_tls_cert_file = /etc/postfix/smtpd.cert
        smtpd_tls_key_file = /etc/postfix/smtpd.key
        smtpd_tls_loglevel = 1
        smtpd_tls_received_header = yes
        smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
        smtpd_use_tls = yes
        transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
        virtual_alias_domains =
        virtual_alias_maps =
        proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf,
        mysql:/etc/postfix/mysql-virtual_email2email.cf
        virtual_gid_maps = static:5000
        virtual_mailbox_base = /var/vmail
        virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
        virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
        virtual_uid_maps = static:5000

        Thanks a lot
        Michele
      • Stan Hoeppner
        ... Unrelated to your question, but... You say this machine is behind a dial up line? Ouch! You may want to seriously consider changing this to something
        Message 3 of 12 , Feb 2 2:36 AM
        • 0 Attachment
          Michele Carandente put forth on 2/2/2010 3:57 AM:

          > message_size_limit = 30720000

          Unrelated to your question, but...

          You say this machine is behind a dial up line? Ouch! You may want to seriously
          consider changing this to something more sane like 262144. With a 56K modem
          averaging a real 45 Kb/s, it will take 47 seconds to transmit a single 256KB
          (262144 bytes) email. For 100 such messages it will take 78 minutes. If you
          allow 1MB (1048576 byte) messages, multiply transmission time by 4, which would
          be just over 5 hours for 100 messages of 1MB each.

          --
          Stan
        • Noel Jones
          ... Ah, I see. Do not add gmail.com or hotmail.com to your mail_domains. Only real local domains go there. To receive mail locally for you@gmail.com, add an
          Message 4 of 12 , Feb 2 8:23 AM
          • 0 Attachment
            On 2/2/2010 3:57 AM, Michele Carandente wrote:
            > Hi Noel,
            > I'll explain better my problem:
            > I've this mailserver under a slow dial-up connection.
            > To fetch email from the main mailserver I use some Perl scripts, and
            > they are working fine.
            > I use postfix to queue the emails that needs to be send and then with
            > the command "postqueue -i" I'll send the emails that I want(they will
            > be relayed with smtp to the correspondent smtp server).
            >
            > In this mailserver I'll have most of the emails with a @...,
            > but also few emails with @... or @...
            > So if I add in mail_users the email user@... and so in
            > mail_domains the gmail.com, everytime that from this mailserver I'll
            > send an email to any @... email, postfix think that it's an
            > internal email and try to delivery it as virtual(Recipient address
            > rejected: User unknown in virtual mailbox table).

            Ah, I see.
            Do not add gmail.com or hotmail.com to your mail_domains.
            Only real local domains go there.

            To receive mail locally for you@..., add an entry to
            virtual_alias_maps (NOT! virtual_alias_domains) like
            you@... you@localhost


            >
            > To say to postfix which smtp server is related with the email, I've
            > used sender_dependent_relayhost_maps.
            > So the only issue that I've is just how to say to postfix which email
            > is an internal one, based on the full email address and not based on
            > just the domain.
            >
            > So I think that the alias in not helping me (but if I'm wrong please
            > let me know :) ).
            >
            > Anyway, this is the output of postconf -n:
            > mailbox_size_limit = 0
            > message_size_limit = 30720000

            That seems awfully generous for a dialup. In particular, you
            should put something for mailbox_size_limit.

            > relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
            > relay_recipient_maps = hash:/etc/postfix/relay_recipient
            > relay_transport = virtual

            This is wrong. The relay_* parameters are for relay domains.
            Don't abuse them by mixing in virtual domains.
            http://www.postfix.org/ADDRESS_CLASS_README.html

            > smtp_tls_loglevel = 2

            Using a TLS loglevel of 2 will give a lot of useless and
            confusing information. Use 1 or 0 unless you have some
            strange problem to track down and you understand what the
            detailed logs mean.

            > smtp_tls_scert_verifydepth = 5

            The default is 9, why do you change it?

            > smtpd_recipient_restrictions = permit_mynetworks,
            > permit_sasl_authenticated, permit_auth_destination,
            > reject_unauth_destination

            Eh? Remove the unneeded permit_auth_destination.

            > smtpd_tls_ask_ccert = yes

            It's wrong to set this to "yes" unless you are using
            certificate based relaying on a dedicated port. Some mailers
            will choke on this.

            > virtual_alias_maps =
            > proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf,
            > mysql:/etc/postfix/mysql-virtual_email2email.cf

            Add your "you@... you@localhost" entry to one of these
            virtual_alias_maps files.

            > virtual_gid_maps = static:5000
            > virtual_mailbox_base = /var/vmail
            > virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
            > virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
            > virtual_uid_maps = static:5000

            OK.

            >
            > Thanks a lot
            > Michele


            http://www.postfix.org/BASIC_CONFIGURATION_README.html
            http://www.postfix.org/SOHO_README.html
            http://www.postfix.org/STANDARD_CONFIGURATION_README.html
            http://www.postfix.org/VIRTUAL_README.html

            -- Noel Jones
          • Michele Carandente
            Hi Noel, Thanks for the corrections... anyway this solution doen t solve the problem that I have. Infact I fetch the email for all my accounts (included gmail
            Message 5 of 12 , Feb 2 9:11 AM
            • 0 Attachment
              Hi Noel,
              Thanks for the corrections... anyway this solution doen't solve the
              problem that I have.
              Infact I fetch the email for all my accounts (included gmail and
              hotmail accounts) with some Perl POP3 scripts.

              I want to use Postfix just to send email(relay it) from a hold queue.

              Let me explain better the configuration:
              this mailserver is back on a dial-up connection.
              On this mailserver I've a @... and some emails from @gmail,
              @hotmail, etc...
              All the emails are not directly send to destination, but all are
              relayed to smtp servers.
              So @... are gonna be relayed to smtp.domain.com.
              However here is where it gets tricky, not all addresses for
              @... are used on this server. Some of them are hosted on
              smtp.domain.com. So user1@... might be valid on our server, but
              our smtp.domain.com server also has user2@... which our server
              is not aware off. So I basically want to relay all emails to
              @... which are NOT valid user mailboxes on our server via our
              second server (smtp.domain.com).
              I would also like to relay privat emails that needs to be sent from
              @...,@... etc to the relative smtp server. However I do
              not which to map these to the local domain.com domain. They should
              have seperate maildirs from the work related accounts.
              If for example I'll cancel 'gmail.com' from mail_domain, I'm able to
              relay without problem emails to smtp.gmail.com.
              The smtp server is decided in the file bysenderrelay, so that for
              every sender I've the correct smtp server.

              Is it more clear? Here is a example list of some users we have,

              Local server
              user1@...
              user2@...

              Internet server (smtp.domain.com)
              user1@...
              user2@...
              user3@...
              user4@...

              So to summerize, I want emails to user3@... to be relayed to
              smtp.domain.com and I want emails to user1@... to be delivered
              locally.

              My main.cf is very messy at the moment as I have tried loads of
              different configurations. Could you point me in the right direction to
              set this up as my above example?

              Thanks a lot for your help

              > To receive mail locally for you@..., add an entry to
              > virtual_alias_maps (NOT! virtual_alias_domains) like
              > you@...  you@localhost
            • Noel Jones
              ... Sorry, that s the only solution I have to offer. -- Noel Jones
              Message 6 of 12 , Feb 2 10:05 AM
              • 0 Attachment
                On 2/2/2010 11:11 AM, Michele Carandente wrote:
                > Hi Noel,
                > Thanks for the corrections... anyway this solution doen't solve the
                > problem that I have.

                Sorry, that's the only solution I have to offer.


                -- Noel Jones

                > Infact I fetch the email for all my accounts (included gmail and
                > hotmail accounts) with some Perl POP3 scripts.
                >
                > I want to use Postfix just to send email(relay it) from a hold queue.
                >
                > Let me explain better the configuration:
                > this mailserver is back on a dial-up connection.
                > On this mailserver I've a @... and some emails from @gmail,
                > @hotmail, etc...
                > All the emails are not directly send to destination, but all are
                > relayed to smtp servers.
                > So @... are gonna be relayed to smtp.domain.com.
                > However here is where it gets tricky, not all addresses for
                > @... are used on this server. Some of them are hosted on
                > smtp.domain.com. So user1@... might be valid on our server, but
                > our smtp.domain.com server also has user2@... which our server
                > is not aware off. So I basically want to relay all emails to
                > @... which are NOT valid user mailboxes on our server via our
                > second server (smtp.domain.com).
                > I would also like to relay privat emails that needs to be sent from
                > @...,@... etc to the relative smtp server. However I do
                > not which to map these to the local domain.com domain. They should
                > have seperate maildirs from the work related accounts.
                > If for example I'll cancel 'gmail.com' from mail_domain, I'm able to
                > relay without problem emails to smtp.gmail.com.
                > The smtp server is decided in the file bysenderrelay, so that for
                > every sender I've the correct smtp server.
                >
                > Is it more clear? Here is a example list of some users we have,
                >
                > Local server
                > user1@...
                > user2@...
                >
                > Internet server (smtp.domain.com)
                > user1@...
                > user2@...
                > user3@...
                > user4@...
                >
                > So to summerize, I want emails to user3@... to be relayed to
                > smtp.domain.com and I want emails to user1@... to be delivered
                > locally.
                >
                > My main.cf is very messy at the moment as I have tried loads of
                > different configurations. Could you point me in the right direction to
                > set this up as my above example?
                >
                > Thanks a lot for your help
                >
                >> To receive mail locally for you@..., add an entry to
                >> virtual_alias_maps (NOT! virtual_alias_domains) like
                >> you@... you@localhost
              • Seth Mattinen
                ... UUCP? ;) ~Seth
                Message 7 of 12 , Feb 2 10:32 AM
                • 0 Attachment
                  On 2/2/10 10:05 AM, Noel Jones wrote:
                  > On 2/2/2010 11:11 AM, Michele Carandente wrote:
                  >> Hi Noel,
                  >> Thanks for the corrections... anyway this solution doen't solve the
                  >> problem that I have.
                  >
                  > Sorry, that's the only solution I have to offer.
                  >

                  UUCP? ;)

                  ~Seth
                • Victor Duchovni
                  ... The OP is perhaps better off crafting his own solution, after reading the relevant documentation. To divert email from the default destination for the
                  Message 8 of 12 , Feb 2 10:34 AM
                  • 0 Attachment
                    On Tue, Feb 02, 2010 at 12:05:18PM -0600, Noel Jones wrote:

                    > On 2/2/2010 11:11 AM, Michele Carandente wrote:
                    >> Hi Noel,
                    >> Thanks for the corrections... anyway this solution doen't solve the
                    >> problem that I have.
                    >
                    > Sorry, that's the only solution I have to offer.

                    The OP is perhaps better off crafting his own solution, after reading
                    the relevant documentation.

                    To divert email from the default destination for the associated domain,
                    it is best to rewrite recipients into an alternate domain that can be
                    handled locally. Alternatively, one can use per-user transport-table
                    entries, but I would not encourage this approach.

                    One can with some care and sophistication use "fallback_transport"
                    and/or "luser_relay" to forward mail for local domains when there is no
                    corresponding local user, but these mechanisms are not robust in my view
                    and explicit rewriting is much better.

                    http://www.postfix.org/ADDRESS_REWRITING_README.html

                    --
                    Viktor.

                    P.S. Morgan Stanley is looking for a New York City based, Senior Unix
                    system/email administrator to architect and sustain our perimeter email
                    environment. If you are interested, please drop me a note.
                  • Michele Carandente
                    Hi to everybody. Thanks for the suggestions. It s look like I ve found what I was looking for... Basically I ve canceled the virtual_mailbox_domains , so that
                    Message 9 of 12 , Feb 3 9:49 AM
                    • 0 Attachment
                      Hi to everybody.
                      Thanks for the suggestions.

                      It's look like I've found what I was looking for...

                      Basically I've canceled the 'virtual_mailbox_domains', so that there
                      are no local domains.

                      All the internal emails are in 'transport_maps =
                      proxy:mysql:/etc/postfix/mysql-virtual_transports.cf', where in
                      mail_transport there all all the internal emails in a column and the
                      word 'virtual' in the other column.

                      If for some reason an internal email is not anymore internal, I'll
                      change 'virtual' with nothing and that email will be relayed as
                      external one...

                      I've tested this solution for all the afternoon and it's look like just fine...

                      Are some of you able to say if there is not a bad part on it that I can not see?

                      Thanks
                      Michele
                    Your message has been successfully submitted and would be delivered to recipients shortly.