"Virtual Users And Domains With Postfix, Courier And MySQL (Ubuntu 6.10 Edgy Eft)"

Discussion in 'HOWTO-Related Questions' started by 4integration, Jun 1, 2007.

  1. falko

    falko Super Moderator Howtoforge Staff

    Please check that the MX record for yout domain points to the right server:
    Code:
    dig mx yourdomain.com
    It seems that mails for system users are sent to mbox instead of Maildir. What's the output of
    Code:
    postconf -n
    ?
     
  2. fowie

    fowie New Member

    More information

    postconf -n returns:
    Code:
    broken_sasl_auth_clients = yes
    config_directory = /etc/postfix
    content_filter = amavis:[127.0.0.1]:10024
    mydestination = localhost, localhost.localdomain
    myhostname = [I]******.com[/I]
    mynetworks = 127.0.0.0/8
    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
    receive_override_options = no_address_mappings
    smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    smtpd_sasl_auth_enable = yes
    smtpd_tls_cert_file = /etc/postfix/smtpd.cert
    smtpd_tls_key_file = /etc/postfix/smtpd.key
    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_create_maildirsize = yes
    virtual_gid_maps = static:5000
    virtual_mailbox_base = /home/vmail
    virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
    virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
    virtual_mailbox_limit_override = yes
    virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
    virtual_maildir_limit_message = "The user you are trying to reach is over quota."
    virtual_overquota_bounce = yes
    virtual_uid_maps = static:5000
    
    I didn't have the mx record, so I just fixed that. I'll let you know what happens.
     
  3. fowie

    fowie New Member

    Ok, so I'm an idiot

    I can admit it. Anyway, the MX record solved that problem with external mail. Now if I can just get it to deliver my /etc/aliases mail from root and others, I'll be set....
     
  4. fowie

    fowie New Member

    Sounds like what I need...

    Falco,

    Everything else seems to be working...thanks for the help. I understand I'll need to add that home_mailbox parameter to my main.cf, but I'm not sure what it should be since my mail directories are all located under /home/vmail now?

    Fowie
     
  5. falko

    falko Super Moderator Howtoforge Staff

    All you need is
    Code:
    virtual_mailbox_base = /home/vmail
    :)
     
  6. fowie

    fowie New Member

    I've got that in my main.cf, but I'm still not getting those mails. Here's my postconf -m:
    Code:
    broken_sasl_auth_clients = yes
    config_directory = /etc/postfix
    content_filter = amavis:[127.0.0.1]:10024
    mydestination = localhost, localhost.localdomain
    myhostname = [I]myhostname.com[/I]
    mynetworks = 127.0.0.0/8
    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
    receive_override_options = no_address_mappings
    smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    smtpd_sasl_auth_enable = yes
    smtpd_tls_cert_file = /etc/postfix/smtpd.cert
    smtpd_tls_key_file = /etc/postfix/smtpd.key
    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_create_maildirsize = yes
    virtual_gid_maps = static:5000
    virtual_mailbox_base = /home/vmail
    virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
    virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
    virtual_mailbox_limit_override = yes
    virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
    virtual_maildir_limit_message = "The user you are trying to reach is over quota."
    virtual_overquota_bounce = yes
    virtual_uid_maps = static:5000
    
     
  7. falko

    falko Super Moderator Howtoforge Staff

    Are the mails you're not receiving for virtual users of for system users?
     
  8. fowie

    fowie New Member

    The mails I'm not receiving are the report emails from some of my cron jobs. They're being emailed to root, my /etc/aliases file redirects like this:

    root: postmaster
    clamav: root
    postmaster: [email protected]
     
  9. falko

    falko Super Moderator Howtoforge Staff

    And is [email protected] a virtual account on the server, or is it an account on a remote system?
     
  10. fowie

    fowie New Member

    It's a virtual account. myemail is an actual user on the system though, and it's /var/mail/myemail where the cron status emails are currently getting sent to.
     
  11. falko

    falko Super Moderator Howtoforge Staff

    Ok, that is the problem. Do you use mydomain.com in the mydestination line in main.cf?
     
  12. fowie

    fowie New Member

    No, I don't have myhostname.com in the mydestination field, it's just
    Code:
    mydestination = localhost, localhost.localdomain
    
     
  13. falko

    falko Super Moderator Howtoforge Staff

    Does it work if you specify another email address (that isn't identical with a system user in the left part)?
     
  14. fowie

    fowie New Member

    No, that doesn't seem to fix it. I chaned my aliases to look like:
    Code:
    # Added by installer for initial user
    root:   postmaster
    clamav: root
    postmaster:     info@[i]myhostname[/i].com
    
    and ran newaliases but checking the email for info using squirrelmail doesn't show me getting any new emails. They're not being delivered to /var/mail/ anymore though either. Now I really have no idea where they are going.
     
  15. falko

    falko Super Moderator Howtoforge Staff

    What's in the mail log when a mail gets sent to root?
     
  16. fowie

    fowie New Member

    I did a
    Code:
    sendmail root
    and sent a test message from the command line and this is what the log shows (mail.info, mail.err did not have anything in it from this command):

    Code:
    Sep 25 13:25:32 localhost postfix/pickup[19012]: D838A7E5CA: uid=1000 from=<fowie>
    Sep 25 13:25:32 localhost postfix/cleanup[19082]: D838A7E5CA: message-id=<20070925192532.D838A7E5CA@[I]myhost[/I].com>
    Sep 25 13:25:32 localhost postfix/qmgr[21477]: D838A7E5CA: from=<fowie@[I]myhost[/I].com>, size=308, nrcpt=1 (queue active)
    
    Sep 25 13:25:42 localhost postfix/qmgr[21477]: CDB697E5CB: from=<fowie@[I]myhost[/I].com>, size=712, nrcpt=1 (queue active)
    Sep 25 13:25:42 localhost amavis[4981]: (04981-09) Passed CLEAN, <fowie@[I]myhost[/I].com> -> <root@[I]myhost[/I].com>, Message-ID: <20070925192532.D838A7E5CA@[I]myhost[/I].com>, mail_id: QshtS7RgLL7w, Hits: 2.167, 9997 ms
    Sep 25 13:25:43 localhost postfix/smtp[19083]: D838A7E5CA: to=<root@[I]myhost[/I].com>, orig_to=<root>, relay=127.0.0.1[127.0.0.1], delay=11, status=sent (250 2.6.0 Ok, id=04981-09, from MTA([127.0.0.1]:10025): 250 Ok: queued as CDB697E5CB)
    Sep 25 13:25:43 localhost postfix/qmgr[21477]: D838A7E5CA: removed
    Sep 25 13:25:43 localhost postfix/virtual[19093]: CDB697E5CB: to=<root@[I]myhost[/I].com>, relay=virtual, delay=1, status=bounced (unknown user: "root@[I]myhost[/I].com")
    Sep 25 13:25:43 localhost postfix/cleanup[19082]: 14D317E5CA: message-id=<20070925192543.14D317E5CA@[I]myhost[/I].com>
    Sep 25 13:25:43 localhost postfix/qmgr[21477]: 14D317E5CA: from=<>, size=2273, nrcpt=1 (queue active)
    Sep 25 13:25:43 localhost postfix/qmgr[21477]: CDB697E5CB: removed
    Sep 25 13:25:43 localhost postfix/virtual[19093]: 14D317E5CA: to=<fowie@[I]myhost[/I].com>, relay=virtual, delay=0, status=sent (delivered to maildir)
    Sep 25 13:25:43 localhost postfix/qmgr[21477]: 14D317E5CA: removed
    
    I noticed that it automatically tried to send the mail I sent to root to root@[I]myhost[/I].com, but I can't put an entry
    Code:
    root@[I]myhost[/I].com: postmaster
    
    in my /etc/aliases file.
     
  17. falko

    falko Super Moderator Howtoforge Staff

    Do you use your hostname (myhost.com) for virtual email addresses? If so, you should change your hostname in /etc/postfix/main.cf.
     
  18. fowie

    fowie New Member

    Yes, I do use my hostname for virtual email addresses. Mostly only because I didn't know it was possible to have emails for users with my hostname not be virtual addresses. What would I change my hostname to? I tried changing it to mail.myhostname.com but I still get a bounce message in my mail.info:
    Code:
    Sep 26 07:57:28 localhost postfix/smtp[21338]: warning: numeric domain name in resource data of MX record for mail.[i]myhost[/i].com: 2[i]my.ip.add.ress[/i]
    Sep 26 07:57:28 localhost postfix/smtp[21329]: C80337E5CA: to=<root@mail.[i]myhost[/i].com>, orig_to=<root>, relay=127.0.0.1[127.0.0.1], delay=8, status=sent (250 2.6.0 Ok, id=04982-08, from MTA([127.0.0.1]:10025): 250 Ok: queued as B4FBB7E5CB)
    Sep 26 07:57:29 localhost postfix/qmgr[21317]: C80337E5CA: removed
    Sep 26 07:57:29 localhost postfix/smtp[21338]: B4FBB7E5CB: to=<root@mail.[i]myhost[/i].com>, relay=none, delay=1, status=bounced (mail for mail.[i]myhost[/i].com loops back to myself)
    Sep 26 07:57:29 localhost postfix/cleanup[21325]: 15CBB7E5CA: message-id=<20070926135729.15CBB7E5CA@mail.[i]myhost[/i].com>
    Sep 26 07:57:29 localhost postfix/qmgr[21317]: 15CBB7E5CA: from=<>, size=2421, nrcpt=1 (queue active)
    Sep 26 07:57:29 localhost postfix/qmgr[21317]: B4FBB7E5CB: removed
    Sep 26 07:57:29 localhost postfix/smtp[21338]: warning: numeric domain name in resource data of MX record for mail.[i]myhost[/i].com: [i]my.ip.add.ress[/i]
    Sep 26 07:57:29 localhost postfix/smtp[21338]: 15CBB7E5CA: to=<fowie@mail.[i]myhost[/i].com>, relay=none, delay=0, status=bounced (mail for mail.[i]myhost[/i].com loops back to myself)
    Sep 26 07:57:29 localhost postfix/qmgr[21317]: 15CBB7E5CA: removed
    
    Another interesting point. Through the process of this conversation I tried chaning my /etc/aliases file so that
    Code:
    postmaster: fowdawgg[at]gmail[dot]com
    
    so it's not going to a local box and I'm still not getting those cron emails sent to me?

    --EDIT--
    I think I've got it now. I had forgotten about the forwardings table in mysql. I was changing the forwardings in /etc/aliases but didn't have an entry in the forwarding table for root@[i]myhost[/i].com
    I'll let you know if that works.

    --Update--
    Yep, works great. Getting all my emails. Thanks for the help!
     
    Last edited: Sep 28, 2007
  19. ruan567

    ruan567 New Member

    Posting to script

    Hi everybody

    I have a similar setup to this - (i just used the tutorial for Dapper Drake) - and now I am wondering how to get the transports table to point to a php script on a regex match for a whole domain? I wish to filter subject lines for a specific clause and if I get a match not pass on the e-mail but reply with php's mail() function. If I don't get a match the mail should go directly to the user's inbox like normal.

    I did a man transport but it seems like there isn't really any method for pointing to a file - the regex bit is supported though.

    Anybody have any ideas?

    Ruan
     
  20. falko

    falko Super Moderator Howtoforge Staff

Share This Page