Find the answer to your Linux question:
Results 1 to 4 of 4
Still a postfix novice. So I'll try and provide as much detail as possible: I have several web sites hosted on the same server. They are each set up as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    3

    configure postfix with domain catch all and sender relays


    Still a postfix novice. So I'll try and provide as much detail as possible:

    I have several web sites hosted on the same server. They are each set up as vhosts.

    Something I don't have any control over is that all outgoing mail from the server has to be sent through an external SMTP. A company called SendGrid.

    SendGrid allows you to set up users with specific whitelisting per domain you're sending emails from.

    So, what I need to do is set up postfix to have different user/password combinations per domain.

    I've found many examples on how to set this up per email address, but because we don't really control the sites (admins can log on to their vhost folder and change whatever they want) I can't guarantee specific email addresses will be the "from" address. So I'd like the rules be per domain rather than per email address.

    Here's the latest of what I've got so far:

    /etc/postfix/main.cf
    Code:
    biff = no
    append_dot_mydomain = no
    smtpd_tls_cert_file=/etc/pki/tls/certs/localhost.crt
    smtpd_tls_key_file=/etc/pki/tls/private/localhost.key
    smtpd_use_tls=yes
    smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
    smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
    smtp_sasl_auth_enable = yes
    # password maps will not work. Customer must provide credentials
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
    smtp_sasl_security_options = noanonymous
    smtp_sender_dependent_authentication = yes
    smtp_use_tls = yes
    myorigin = $myhostname
    smtpd_banner = $myhostname ESMTP $mail_name 
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    mydestination = , doctor-teeth, localhost.localdomain, localhost
    relayhost = [smtp.sendgrid.net]:587
    mynetworks = 127.0.0.0/8
    inet_interfaces = loopback-only
    mailbox_size_limit = 0
    recipient_delimiter = +
    /etc/postfix/sasl_passwd (domain/credentials edited to preserve security)
    Code:
    domain.com   user:password
    /etc/postfix/sender_relay (domain edited to preserve security)
    Code:
    domain.com       [smtp.sendgrid.net]:587
    Every time I make a change to these config files I run the following:
    Code:
    postmap /etc/postfix/sasl_passwd
    postmap /etc/postfix/sender_relay
    service postfix restart
    However, emails always fails to authenticate at SendGrid because it doesn't find the credentials and use them. Here's the error from the logs: (Also, note that I use a § for the AT symbol everywhere because my account is new and it wouldn't let me post with them in it, even though I wasn't having it parse for links, nor was I linking to anything... I tried using the entity but that didn't work either. Sorry for that.)

    sent via php interactive (php -a):
    Code:
    mail('plath§domain.com', 'test', 'test', 'From: test§domain.com', '-f test§domain.com');
    /var/log/maillog (domain edited for security; and yes, this server is called "doctor-teeth"; all our servers are muppet themed)
    Code:
    Aug 15 14:56:25 doctor-teeth postfix/postfix-script: starting the Postfix mail system
    Aug 15 14:56:25 doctor-teeth postfix/master[22305]: daemon started -- version 2.3.3, configuration /etc/postfix
    Aug 15 14:56:32 doctor-teeth postfix/pickup[22307]: 8F2B78B8A93: uid=0 from=<test§domain.com>
    Aug 15 14:56:32 doctor-teeth postfix/cleanup[22312]: 8F2B78B8A93: message-id=<20110815195632.8F2B78B8A93§doctor-teeth.localdomain>
    Aug 15 14:56:32 doctor-teeth postfix/qmgr[22308]: 8F2B78B8A93: from=<test&#x0040;domain.com>, size=394, nrcpt=1 (queue active)
    Aug 15 14:56:33 doctor-teeth postfix/smtp[22314]: 8F2B78B8A93: to=<plath&#x0040;domain.com>, relay=smtp.sendgrid.net[174.36.32.204]:587, delay=0.48, delays=0.06/0.19/0.2/0.03, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[174.36.32.204] said: 550 Cannot receive from specified address <test&#x0040;test.com>: Unauthenticated senders not allowed (in reply to MAIL FROM command))
    Aug 15 14:56:33 doctor-teeth postfix/cleanup[22312]: 317B68B8A96: message-id=<20110815195633.317B68B8A96&#x0040;doctor-teeth.localdomain>
    Aug 15 14:56:33 doctor-teeth postfix/qmgr[22308]: 317B68B8A96: from=<>, size=2475, nrcpt=1 (queue active)
    Aug 15 14:56:33 doctor-teeth postfix/bounce[22316]: 8F2B78B8A93: sender non-delivery notification: 317B68B8A96
    Aug 15 14:56:33 doctor-teeth postfix/qmgr[22308]: 8F2B78B8A93: removed
    Aug 15 14:56:33 doctor-teeth postfix/smtp[22314]: 317B68B8A96: to=<test&#x0040;domain.com>, relay=smtp.sendgrid.net[174.36.32.204]:587, delay=0.27, delays=0.06/0/0.2/0.02, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[174.36.32.204] said: 550 Cannot receive from specified address <>: Unauthenticated senders not allowed (in reply to MAIL FROM command))
    Aug 15 14:56:33 doctor-teeth postfix/qmgr[22308]: 317B68B8A96: removed
    Aug 15 15:07:13 doctor-teeth postfix/postfix-script: stopping the Postfix mail system
    Aug 15 15:07:13 doctor-teeth postfix/master[22305]: terminating on signal 15
    If I understand correctly, the reason there are two failed attempts each time is because it first looks for the email address, and when that fails it tries to find a generic rule. I'd love to add a third attempt before generic that is "domain".

    I have tried setting sasl_password to use "§domain.com" and a variety of typical wildcard characters such as "*§domain.com" and "%§domain.com". These failed.

    The reason I'm sending the additional parameters in the php call is that for it to work with SendGrid in the first place you have to send both the From: header and the -f additional parameter.

    I'm open to any suggestions. Thank you so much for your help.

    (sorry if this double-posts, had issues with the login while writing/posting it)

  2. #2
    Just Joined!
    Join Date
    Aug 2011
    Posts
    1
    Hi !

    You might be able to find help here (don't hesitate to ask in the comments section, the guy is really nice)

    marknelson.us/2011/07/06/sendmail-on-linux-the-easy-way/
    marknelson.us/2011/07/31/more-on-sending-mail-with-linux-postfix-tweaks-and-mailjet/

    hope this helps !

  3. #3
    Just Joined!
    Join Date
    Aug 2011
    Posts
    3
    Thank you for pointing me towards those sites. Unfortunately they don't address my situation, but I did leave a comment asking him to take a look at this thread to help out. But that's been a week or two, now. Does anyone else have any ideas? Thank you!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Aug 2011
    Posts
    3
    Bump. Still trying to get to the bottom of this. I'm reading all the postfix documentation, but a lot of it is over my head. Any help would be appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •