how to configure postfix to send email out for a hosted domain

Discussion in 'Server Operation' started by nox171, Jun 13, 2007.

  1. nox171

    nox171 New Member

    Hiya all,

    i'm having a problem with my Suse server.
    I've installed on it ISPConfig with several websites.

    Also i've an OScommerce installation running on it...
    Let me describe my scenario:

    a user is buying something on the shop.
    When the purchase is done, oscommerce send a confirmation email to the user.
    Everything is fine but not if the user's email domain is hosted on the server.

    ie:
    [email protected] purchase something -> email sent correctly.
    [email protected] purchase something -> the postmaster (myself) receive a bouceback like this:
    Code:
     The e-mail system was unable to deliver the message, but did not report a specific reason.  Check the address and try again.  If it still fails, contact your system administrator.
                < server1.xxxxxxx.com #5.0.0 X-Postfix; unknown user: "demouser">
    
    I think the mailserver is not sending the email because the email domain address is hosted on the server.
    The point is that the domain has not the mailserver on my server but the client is managing it. The MX server is outside the ISPConfig server...

    I hope everything is clear... :)
    How can I configure postfix to look outside the server and send the email??

    thanks
    /nox
     
  2. nox171

    nox171 New Member

    Any idea??
     
  3. falko

    falko Super Moderator Howtoforge Staff

    Does [email protected] exist in /etc/postfix/virtusertable? What's the output of
    Code:
    postconf -n
    ?
     
  4. nox171

    nox171 New Member

    Hi falko,
    inside the vitusertable there isn't that user.

    This is the output postconf -n:

    Code:
    alias_maps = hash:/etc/aliases
    biff = no
    broken_sasl_auth_clients = yes
    canonical_maps = hash:/etc/postfix/canonical
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/lib/postfix
    debug_peer_level = 2
    defer_transports =
    disable_dns_lookups = no
    disable_mime_output_conversion = no
    html_directory = /usr/share/doc/packages/postfix/html
    inet_interfaces = all
    inet_protocols = all
    mail_owner = postfix
    mail_spool_directory = /var/mail
    mailbox_command =
    mailbox_size_limit = 0
    mailbox_transport =
    mailq_path = /usr/bin/mailq
    manpage_directory = /usr/share/man
    masquerade_classes = envelope_sender, header_sender, header_recipient
    masquerade_domains =
    masquerade_exceptions = root
    message_size_limit = 10240000
    mydestination = /etc/postfix/local-host-names
    mydomain = [I]myserver[/I]hosts.com
    myhostname = server1.$mydomain
    newaliases_path = /usr/bin/newaliases
    queue_directory = /var/spool/postfix
    readme_directory = /usr/share/doc/packages/postfix/README_FILES
    relayhost =
    relocated_maps = hash:/etc/postfix/relocated
    sample_directory = /usr/share/doc/packages/postfix/samples
    sender_canonical_maps = hash:/etc/postfix/sender_canonical
    sendmail_path = /usr/sbin/sendmail
    setgid_group = maildrop
    smtp_sasl_auth_enable = no
    smtp_tls_note_starttls_offer = yes
    smtp_use_tls = yes
    smtpd_client_restrictions =
    smtpd_helo_required = no
    smtpd_helo_restrictions =
    smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,check_relay_domains
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain =
    smtpd_sasl_security_options = noanonymous
    smtpd_sender_restrictions = hash:/etc/postfix/access
    smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
    smtpd_tls_auth_only = no
    smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
    smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
    smtpd_tls_loglevel = 1
    smtpd_tls_received_header = yes
    smtpd_tls_session_cache_timeout = 3600s
    smtpd_use_tls = yes
    strict_8bitmime = no
    strict_rfc821_envelopes = no
    tls_random_source = dev:/dev/urandom
    transport_maps = hash:/etc/postfix/transport
    unknown_local_recipient_reject_code = 550
    
    Ta
     
    Last edited: Jun 15, 2007
  5. falko

    falko Super Moderator Howtoforge Staff

    /etc/postfix/virtusertable isn't included in your Postfix configuration. Please run
    Code:
    postconf -e 'virtual_maps = hash:/etc/postfix/virtusertable'
    /etc/init.d/postfix restart
    And then you must create the email address [email protected] in ISPConfig, because if it doesn't exist, you can't send to it.
     
  6. nox171

    nox171 New Member

    Sorry, but I'm not getting that.

    Why OSCommerce can send email to "[email protected]" and cannot to "@hosteddomain.xxx" ?
    Just to be clear the client has just pointed one A Record on my server.
    They have their own server for the website and for the email as well.

    They are pointing to my server for shop.clientdomain.xxx

    Thanks!
     
  7. falko

    falko Super Moderator Howtoforge Staff

    You must create a "CatchAll Account" if you want to send emails to @hosteddomain.xxx.
     
  8. nox171

    nox171 New Member

    I'm worried to do some changes to the actual configuration of the entire server because I've got a lot of website on it and they are working all fine.

    So I'd like to be really sure before do anything.

    I just need ISPConfig to be able to send the email to a @hosteddomain.xxx email address but without looking inside "himself".
    Because, of course the user do not exists on the localhost. The email address is hosted somewhere else, where the real mailserver is.

    Is there a way to do it?
    Because now you gave me 2 information and I'm not sure witch way I should take.


    For example if I create the user in ISPConfig and enable the "External Mailserver" option will it send the email without looking inside the server for the user?

    Thanks!!
     
  9. falko

    falko Super Moderator Howtoforge Staff

    Well, at least you must do this:

    Code:
    postconf -e 'virtual_maps = hash:/etc/postfix/virtusertable'
    /etc/init.d/postfix restart
    Yes.
     
  10. nox171

    nox171 New Member

    Hello again.
    I did what you said Falko.
    Now it seems to work with the main email "[email protected]", this is the email address that i've add to ISPConfig,
    but it is not working if a user with the same domain but a different address i.e. "[email protected]" purchases something!

    Do I have to create every user that my client has in is mailserver??

    Are we sure isn't there a solution to "route" postifix directly outside itself (localhost) to look for the user and just send the email??

    Many thanks!
     
  11. nox171

    nox171 New Member

    This is the log from postfix:

    Code:
    
    Jun 21 15:14:24 server1 postfix/pickup[9647]: D5E4125405A: uid=30 from=<wwwrun>
    Jun 21 15:14:24 server1 postfix/cleanup[10861]: D5E4125405A: message-id=<[email protected]>
    Jun 21 15:14:24 server1 postfix/qmgr[22433]: D5E4125405A: from=<[email protected]>, size=1470, nrcpt=1 (queue active)
    Jun 21 15:14:24 server1 postfix/pickup[9647]: EBFAA254058: uid=30 from=<wwwrun>
    Jun 21 15:14:24 server1 postfix/cleanup[10861]: EBFAA254058: message-id=<[email protected]>
    Jun 21 15:14:25 server1 postfix/qmgr[22433]: EBFAA254058: from=<[email protected]>, size=1458, nrcpt=1 (queue active)
    Jun 21 15:14:25 server1 postfix/local[10865]: D5E4125405A: to=[b]<[email protected]>[/b], relay=local, delay=1, status=bounced (unknown user: "not_info")
    Jun 21 15:14:25 server1 postfix/cleanup[10861]: 2677D25405F: message-id=<[email protected]>
    Jun 21 15:14:25 server1 postfix/local[10868]: EBFAA254058: to=<[email protected]>, orig_to=<[email protected]>, relay=local, delay=1, status=sent (delivered to command: /usr/bin/procmail -f-)
    Jun 21 15:14:25 server1 postfix/qmgr[22433]: EBFAA254058: removed
    
    As you can see the email to [email protected] has been delivered with no problem (because now it is in ISPConfig and the "External Mailserver" has been enabled), but the other email to [email protected] has not (because the user doesn't exist in ISPConfig)

    I really need a solution for this, if anyone has an idea please tell me!
     
    Last edited: Jun 21, 2007
  12. falko

    falko Super Moderator Howtoforge Staff

    Can you post the contents of /etc/postfix/local-host-names and /etc/postfix/virtusertable? What's the output of
    Code:
    postconf -n
    ?

    There must be an email account for [email protected] on the receiving mail server.
     
  13. nox171

    nox171 New Member

    I'm sorry but for privacy reasons I can't post here the content of /etc/postfix/local-host-names and /etc/postfix/virtusertable :(
    Maybe if you tell me what I have to look for...

    This is the output for

    postconf -n:

    Code:
    
    server1:~ # postconf -n
    alias_maps = hash:/etc/aliases
    biff = no
    broken_sasl_auth_clients = yes
    canonical_maps = hash:/etc/postfix/canonical
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/lib/postfix
    debug_peer_level = 2
    defer_transports =
    disable_dns_lookups = no
    disable_mime_output_conversion = no
    html_directory = /usr/share/doc/packages/postfix/html
    inet_interfaces = all
    inet_protocols = all
    mail_owner = postfix
    mail_spool_directory = /var/mail
    mailbox_command =
    mailbox_size_limit = 0
    mailbox_transport =
    mailq_path = /usr/bin/mailq
    manpage_directory = /usr/share/man
    masquerade_classes = envelope_sender, header_sender, header_recipient
    masquerade_domains =
    masquerade_exceptions = root
    message_size_limit = 10240000
    mydestination = /etc/postfix/local-host-names
    mydomain = [i]myhosts[/i].com
    myhostname = server1.$mydomain
    newaliases_path = /usr/bin/newaliases
    queue_directory = /var/spool/postfix
    readme_directory = /usr/share/doc/packages/postfix/README_FILES
    relayhost =
    relocated_maps = hash:/etc/postfix/relocated
    sample_directory = /usr/share/doc/packages/postfix/samples
    sender_canonical_maps = hash:/etc/postfix/sender_canonical
    sendmail_path = /usr/sbin/sendmail
    setgid_group = maildrop
    smtp_sasl_auth_enable = no
    smtp_tls_note_starttls_offer = yes
    smtp_use_tls = yes
    smtpd_client_restrictions =
    smtpd_helo_required = no
    smtpd_helo_restrictions =
    smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,check_relay_domains
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain =
    smtpd_sasl_security_options = noanonymous
    smtpd_sender_restrictions = hash:/etc/postfix/access
    smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
    smtpd_tls_auth_only = no
    smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
    smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
    smtpd_tls_loglevel = 1
    smtpd_tls_received_header = yes
    smtpd_tls_session_cache_timeout = 3600s
    smtpd_use_tls = yes
    strict_8bitmime = no
    strict_rfc821_envelopes = no
    tls_random_source = dev:/dev/urandom
    transport_maps = hash:/etc/postfix/transport
    unknown_local_recipient_reject_code = 550
    
    Of course there is an account for [email protected] on the receiving mail server but, as I can understand, postfix just looks inside without trying to send the email. It thinks to be the mailserver. It looks for the user and cannot find it. So I, as a postmaster, receive the email of not delivery report with "user unknow" as error.

    Making a practical example:

    this is the shop address: shop.examplegift.com
    shop owner email address: bookings.examplegift.com
    client1 email address (generic): [email protected]
    clent2 email address (same company): [email protected]


    Case 1:
    Someone with a generic email address (client1) registers himself on the OSCommerce shop.
    When he purchases something there are two emails sent. One email is sent to the shop owner and the other to the client.
    Mail to the owner: OK (since I've added the user on ISPConfig - see previous post)
    Mail to client1: OK

    Case 2:
    Someone from the same shop's company, or someone else for whom i'm hosting the website on the same server, purchases anything this is what happens:

    Mail to owner: OK
    Mail to client2: postmaster receives the NDR (user unknow)


    I hope that the picture of the situation is clearer now.
    This is really odd and for me, not a good linux user :rolleyes: , it is very difficult to fix something like that.

    Thanks
     
    Last edited: Jun 23, 2007
  14. falko

    falko Super Moderator Howtoforge Staff

    Code:
    virtual_maps = hash:/etc/postfix/virtusertable
    is still missing in /etc/postfix/main.cf. Please add it and restart Postfix (I mean it).
     
  15. daveb

    daveb Member

    nox171 did your customer setup in oscommerce admin to send from the user "email address" hosted on your server or from one of their existing users "email address"
     
  16. nox171

    nox171 New Member

    I have created the email address in ISPCofig and then enabled the "external Mailserver" funcion, but the user is not hosted on my mailserver.

    Falko I tried the command again as you suggest:
    Code:
    server1:~ # postconf -e 'virtual_maps = hash:/etc/postfix/virtusertable'
    server1:~ # /etc/init.d/postfix restart
    Shutting down mail service (Postfix)                                 done
    Starting mail service (Postfix)                                      done
    server1:~ #
    
    but then looking in it I still don't see the /etc/postfix/virtusertable!
    Code:
    
    server1:~ # postconf -n
    alias_maps = hash:/etc/aliases
    biff = no
    broken_sasl_auth_clients = yes
    canonical_maps = hash:/etc/postfix/canonical
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/lib/postfix
    debug_peer_level = 2
    defer_transports =
    disable_dns_lookups = no
    disable_mime_output_conversion = no
    html_directory = /usr/share/doc/packages/postfix/html
    inet_interfaces = all
    inet_protocols = all
    mail_owner = postfix
    mail_spool_directory = /var/mail
    mailbox_command =
    mailbox_size_limit = 0
    mailbox_transport =
    mailq_path = /usr/bin/mailq
    manpage_directory = /usr/share/man
    masquerade_classes = envelope_sender, header_sender, header_recipient
    masquerade_domains =
    masquerade_exceptions = root
    message_size_limit = 10240000
    mydestination = /etc/postfix/local-host-names
    mydomain = n1hosts.com
    myhostname = server1.$mydomain
    newaliases_path = /usr/bin/newaliases
    queue_directory = /var/spool/postfix
    readme_directory = /usr/share/doc/packages/postfix/README_FILES
    relayhost =
    relocated_maps = hash:/etc/postfix/relocated
    sample_directory = /usr/share/doc/packages/postfix/samples
    sender_canonical_maps = hash:/etc/postfix/sender_canonical
    sendmail_path = /usr/sbin/sendmail
    setgid_group = maildrop
    smtp_sasl_auth_enable = no
    smtp_tls_note_starttls_offer = yes
    smtp_use_tls = yes
    smtpd_client_restrictions =
    smtpd_helo_required = no
    smtpd_helo_restrictions =
    smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,check                                                                              _relay_domains
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain =
    smtpd_sasl_security_options = noanonymous
    smtpd_sender_restrictions = hash:/etc/postfix/access
    smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
    smtpd_tls_auth_only = no
    smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
    smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
    smtpd_tls_loglevel = 1
    smtpd_tls_received_header = yes
    smtpd_tls_session_cache_timeout = 3600s
    smtpd_use_tls = yes
    strict_8bitmime = no
    strict_rfc821_envelopes = no
    tls_random_source = dev:/dev/urandom
    transport_maps = hash:/etc/postfix/transport
    unknown_local_recipient_reject_code = 550
    
    Do you know why??
     
  17. falko

    falko Super Moderator Howtoforge Staff

    Can you add
    Code:
    virtual_maps = hash:/etc/postfix/virtusertable
    manually to /etc/postfix/main.cf then and restart Postfix?
     
  18. nox171

    nox171 New Member

    I opened the file but the virtusertable line was already there!
    :confused:

    Someone can tell me what's going on here??
     
  19. falko

    falko Super Moderator Howtoforge Staff

    Can you run
    Code:
    updatedb
    locate main.cf
    and post the output?
    How did you install Postfix? Did you use your distribution's package, or did you compile it yourself?
     
  20. nox171

    nox171 New Member

    here the output
    Code:
    /etc/postfix/main.cf
    /etc/postfix/main.cf.default
    /etc/postfix/main.cf.orig
    /etc/postfix/main.cf.SuSEconfig
    /var/adm/backup/postfix/main.cf
    /var/adm/SuSEconfig/md5/etc/postfix/main.cf
    
    I didn't install the box, it has been done by the previous IT manager.
    It should be a normal installation of ISPConfig following the how to in this forum.
    The distro is a suse.
     
    Last edited: Jul 5, 2007

Share This Page