Page 23 of 51 FirstFirst ... 13212223242533 ... LastLast
Results 221 to 230 of 506

Thread: Howto: set up a mail server in Ubuntu

  1. #221
    Join Date
    May 2009

    Re: Howto: set up a mail server in Ubuntu

    Flurdy: great tutorial! This is the most complete tutorial I've seen out there - thank you so much for putting the time and effort into this.

    My issue has to do with getting bounced emails when using a relayhost. I've added this wrinkle to the Postfix config to circumvent the SPAM suppression my ISP (& which most good ones do) on port 25. Unfortunately, one side-effect of my attempt is that my configuration is auto-forwarding any incoming emails to my forwarding service. What am I doing wrong?

    Here's the mail log output:
    May 11 16:39:00 mail postfix/smtpd[25335]: connect from[]
    May 11 16:39:01 mail postfix/smtpd[25335]: 0E33218880A:[]
    May 11 16:39:01 mail postfix/cleanup[25330]: 0E33218880A: message-id=<>
    May 11 16:39:01 mail postfix/qmgr[25118]: 0E33218880A: from=<>, size=2613, nrcpt=1 (queue active)
    May 11 16:39:01 mail amavis[2631]: (02631-19) ESMTP::10024 /var/lib/amavis/tmp/amavis-20090506T093443-02631: <> -> <testuser@example.c> SIZE=2613 Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP for <testuser@example.c>; Mon, 11 May 2009 16:39:01 -0700 (PDT)
    May 11 16:39:01 mail postfix/smtpd[25335]: disconnect from[]
    May 11 16:39:01 mail amavis[2631]: (02631-19) smtp connection cache, dt: 154.9, state: 0
    May 11 16:39:01 mail amavis[2631]: (02631-19) dkim: VALID Author+Sender+MailFrom signature by, From: <>, a=rsa-sha256, c=relaxed/relaxed, s=s1024,
    May 11 16:39:01 mail amavis[2631]: (02631-19) dkim: VALID Author+Sender+MailFrom signature by, From: <>, a=rsa-sha1, c=nofws, s=s1024,
    May 11 16:39:01 mail amavis[2631]: (02631-19) Checking: UNH1HEO39P8B [] <> -> <testuser@example.c>
    May 11 16:39:01 mail amavis[2631]: (02631-19) p003 1 Content-Type: multipart/alternative
    May 11 16:39:01 mail amavis[2631]: (02631-19) p001 1/1 Content-Type: text/plain, size: 9 B, name: 
    May 11 16:39:01 mail amavis[2631]: (02631-19) p002 1/2 Content-Type: text/html, size: 127 B, name: 
    May 11 16:39:01 mail postfix/smtpd[25332]: connect from localhost[]
    May 11 16:39:01 mail postfix/smtpd[25332]: 5770B188810: client=localhost[]
    May 11 16:39:01 mail postfix/cleanup[25330]: 5770B188810: message-id=<>
    May 11 16:39:01 mail postfix/qmgr[25118]: 5770B188810: from=<>, size=3239, nrcpt=1 (queue active)
    May 11 16:39:01 mail postfix/smtpd[25332]: disconnect from localhost[]
    May 11 16:39:01 mail amavis[2631]: (02631-19) FWD via SMTP: <> -> <testuser@example.c>,BODY=7BIT 250 2.0.0 Ok, id=02631-19, from MTA([]:10025): 250 2.0.0 Ok: queued as 5770B188810
    May 11 16:39:01 mail amavis[2631]: (02631-19) Passed CLEAN, [] [] <> -> <testuser@example.c>, Message-ID: <>, mail_id: UNH1HEO39P8B, Hits: -, size: 2610, queued_as: 5770B188810,,, 340 ms
    May 11 16:39:01 mail postfix/smtp[25331]: 0E33218880A: to=<testuser@example.c>, orig_to=<>, relay=[]:10024, delay=0.79, delays=0.43/0/0.01/0.35, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=02631-19, from MTA([]:10025): 250 2.0.0 Ok: queued as 5770B188810)
    May 11 16:39:01 mail postfix/qmgr[25118]: 0E33218880A: removed
    May 11 16:39:01 mail amavis[2631]: (02631-19) TIMING [total 358 ms] - SMTP greeting: 3 (1%)1, SMTP EHLO: 2 (0%)1, SMTP pre-MAIL: 2 (1%)2, SMTP pre-DATA-flush: 4 (1%)3, SMTP DATA: 33 (9%)13, check_init: 2 (1%)13, digest_hdr: 62 (17%)30, digest_body_dkim: 4 (1%)32, gen_mail_id: 9 (3%)34, mime_decode: 33 (9%)43, get-file-type2: 21 (6%)49, parts_decode: 0 (0%)49, check_header: 5 (1%)51, update_cache: 3 (1%)52, decide_mail_destiny: 1 (0%)52, fwd-connect: 50 (14%)66, fwd-mail-pip: 6 (2%)67, fwd-rcpt-pip: 1 (0%)68, fwd-data-chkpnt: 0 (0%)68, write-header: 3 (1%)69, fwd-data-contents: 0 (0%)69, fwd-end-chkpnt: 41 (11%)80, prepare-dsn: 7 (2%)82, main_log_entry: 51 (14%)96, update_snmp: 5 (1%)98, SMTP pre-response: 1 (0%)98, SMTP response: 2 (0%)98, unlink-2-files: 1 (0%)99, rundown: 5 (1%)100
    May 11 16:39:01 mail CRON[25337]: pam_unix(cron:session): session opened for user root by (uid=0)
    May 11 16:39:01 mail dbus-daemon: Rejected send message, 1 matched rules; type="method_call", sender=":1.43" (uid=1000 pid=4498 comm="/usr/lib/indicator-applet/indicator-applet --oaf-a") interface="org.freedesktop.DBus.Properties" member="Get" error name="(unset)" requested_reply=0 destination=":1.760" (uid=0 pid=25337 comm="/USR/SBIN/CRON "))
    May 11 16:39:01 mail /USR/SBIN/CRON[25344]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm)
    May 11 16:39:01 mail CRON[25337]: pam_unix(cron:session): session closed for user root
    May 11 16:39:02 mail postfix/smtp[25333]: 5770B188810: to=<testuser@example.c>,[]:2525, delay=0.88, delays=0.04/0/0.73/0.11, dsn=5.0.0, status=bounced (host[] said: 550 testuser@example.c failed recipient verification (in reply to RCPT TO command))
    May 11 16:39:02 mail postfix/cleanup[25330]: 502DE188811: message-id=<>
    May 11 16:39:02 mail postfix/qmgr[25118]: 502DE188811: from=<>, size=5292, nrcpt=1 (queue active)
    May 11 16:39:02 mail postfix/bounce[25334]: 5770B188810: sender non-delivery notification: 502DE188811
    May 11 16:39:02 mail postfix/qmgr[25118]: 5770B188810: removed
    May 11 16:39:03 mail postfix/smtp[25333]: 502DE188811: to=<>,[]:2525, delay=1.1, delays=0.01/0/0.7/0.41, dsn=2.0.0, status=sent (250 OK id=1M3f5L-0000uK-2h)
    May 11 16:39:03 mail postfix/qmgr[25118]: 502DE188811: removed
    Next the result of postconf -n:

    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    append_at_myorigin = no
    append_dot_mydomain = no
    biff = no
    config_directory = /etc/postfix
    content_filter = amavis:[]:10024
    delay_warning_time = 4h
    disable_vrfy_command = yes
    inet_interfaces = all
    local_recipient_maps = 
    mailbox_size_limit = 0
    masquerade_domains =
    masquerade_exceptions = root
    maximal_backoff_time = 8000s
    maximal_queue_lifetime = 3d
    minimal_backoff_time = 1000s
    mydestination = 
    mydomain =
    myhostname =
    mynetworks = [::ffff:]/104 [::1]/128
    mynetworks_style = host
    myorigin = $mydomain
    readme_directory = no
    recipient_delimiter = +
    relayhost =
    smtp_helo_timeout = 60s
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
    smtp_sasl_security_options = 
    smtp_tls_CAfile = /etc/ssl/certs/Equifax_Secure_CA.pem
    smtp_tls_note_starttls_offer = yes
    smtp_tls_security_level = may
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    smtp_use_tls = yes
    smtpd_banner = $myhostname ESMTP $mail_name
    smtpd_client_restrictions = reject_rbl_client, reject_rbl_client, reject_rbl_client
    smtpd_data_restrictions = reject_unauth_pipelining
    smtpd_delay_reject = yes
    smtpd_hard_error_limit = 12
    smtpd_helo_required = yes
    smtpd_helo_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_hostname, reject_invalid_hostname, permit
    smtpd_recipient_limit = 16
    smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, permit
    smtpd_sender_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit
    smtpd_soft_error_limit = 3
    smtpd_tls_cert_file = /etc/postfix/postfix.cert
    smtpd_tls_key_file = /etc/postfix/postfix.key
    smtpd_tls_received_header = yes
    smtpd_tls_security_level = may
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    tls_random_source = dev:/dev/urandom
    unknown_local_recipient_reject_code = 450
    virtual_alias_maps = mysql:/etc/postfix/
    virtual_gid_maps = mysql:/etc/postfix/
    virtual_mailbox_base = /var/spool/mail/virtual
    virtual_mailbox_domains = mysql:/etc/postfix/
    virtual_mailbox_maps = mysql:/etc/postfix/
    virtual_uid_maps = mysql:/etc/postfix/
    A few notes about my configuration/environment. I am using a home router w/ my own domain name ( The mail server ( is running on Ubuntu 9.04 behind the home router. The router is set up to forward all of the relevant ports to the Ubuntu server. (Port 25 for SMTP and 143 for IMAP)

    Also, I've checked my router and DNS records against the documentation, and I think I've got the MX records set up properly. (not totally confident there...) I've tested the setup externally, using mxtools. ( a very helpful tool!) Everything there checks out, except its attempt to telnet into Here's the result:

    May 11 16:24:17 mail postfix/smtpd[25121]: connect from[]
    May 11 16:24:18 mail postfix/smtpd[25121]: NOQUEUE: reject: RCPT from[]: 554 5.7.1 <>: Relay access denied; from=<> to=<> proto=SMTP helo=<>
    May 11 16:24:18 mail postfix/smtpd[25121]: disconnect from[]
    Not sure if this has anything to do w/ my issue, but maybe it will provide some clues...

    Thanks for the help, in advance.


  2. #222
    Join Date
    May 2009

    Re: Howto: set up a mail server in Ubuntu

    OK. Problem solved.

    As it turns out, this problem has nothing to do with the configuration files listed above. Instead, I had the account self-referenced in the MySQL aliases table like this:

    pkid          mail                           destination                 enabled
    1              1
    So, the Postfix virtual mail delivery system was finding this erroneous entry in the 'aliases' table and then forwarding it on.

    Hope this helps someone in the future!

  3. #223
    Join Date
    May 2009
    Oslo, Norway
    Ubuntu 9.04 Jaunty Jackalope

    Re: Howto: set up a mail server in Ubuntu

    Thanks for a great tutorial, Flurdy!

    I have managed to complement Flurdy's tutorial such that virtual transport is swapped for maildrop and spam is automatically delivered to a spam folder.

    It is based on the excellent tutorial by Flurdy and complemented by parts of the tutorial found here:

    The latter tutorial also contains methods to implement vacation messaging.

    If in doubt, check out the forementioned tutorial.

    Here's what I did:

    Complete Flurdy's tutorial and install maildrop

    uncomment in
    transport_maps = mysql:/etc/postfix/
    and add
    maildrop_destination_recipient_limit = 1 file should contain the following line, change the user field to virtual:
    maildrop  unix  -       n       n       -       -       pipe
      flags=DRhu user=virtual argv=/usr/bin/maildrop -d ${recipient}
    create file and set the correct owner and permissions:
    additional_conditions = and enabled = 1
    # cd /var/spool/mail/virtual/
    # chmod +s /usr/bin/maildrop
    # touch .mailfilter
    # chmod 600 .mailfilter
    # mkdir mailfilters
    # chmod 700 mailfilters
    # chown -R virtual:virtual .mailfilter mailfilters
    test maildrop and check logs:
    echo "test" | maildrop -V 9 -d
    Edit the ...virtual/.mailfilter file (haven't tested this bit):
    # Deliver to Inbox or Spam box (create spam box if it does not exist)
    if (/^X-Spam-Flag: YES/:h)
        `test -d $DEFAULT/.junkmail`
        if ($RETURNCODE == 1)
            `/usr/bin/maildirmake -f junkmail $DEFAULT`
            `echo "junkmail" >> $DEFAULT/subscriptions`
        exception {
            to "$DEFAULT/.junkmail"
        # if all else fails, do regular delivery
        exception {
            to "$DEFAULT"
    Now use phpmyadmin and change domain transport field from "virtual:" to "maildrop:"

    Restart postfix, check log files and pray

    Much of the code here is curtesy of hamba from

    Hope this helps!

    Cheers, Villu

  4. #224
    Join Date
    Apr 2005

    Smile Re: Howto: set up a mail server in Ubuntu

    Quote Originally Posted by fusa View Post
    In your example located at:

    INSERT INTO users (id,name,maildir,clear) VALUES ('','xandros','xandros/', encrypt('apassword') ), ('','vivita','vivita/', encrypt('anotherpassword') );

    should the maildir,clear) actually be maildir,crypt) It looks like your inserting the encrypted password into the clear text field.

    Umm, yes good point.
    Ivar (

  5. #225
    Join Date
    Apr 2005

    Cool Re: Howto: set up a mail server in Ubuntu

    Quote Originally Posted by sTo0z View Post

    I was wondering what you're advice would be on the best way to back this system up.

    I am not knowledgeable so the best solution I can think of is to maybe rsync each user's folder and then dump the mysql data... is that what you would do?

    I'm sure there's something better out there, I just don't know what it is.. I don't really know how I would back up the whole thing.

    Any and all help is appreciated, thank you!

    PS - Awesome guide, I followed your guide from 6.06 awhile back and the email server is still chugging along perfectly. I was a hero at work thanks to you.

    I (very briefly) do mention backing up in this section:
    But there probably are other more elaborate solutions to this, and mine may have some integrety or security issue. But that is all I do, and it works.

    Good to hear the server is still working, and you got some cred for it!
    Ivar (

  6. #226
    Join Date
    Apr 2005

    Post Re: Can't access port 25

    Quote Originally Posted by mariuxx View Post
    Hi again, and thanks for your answer, flurdy.
    Now I suppose I should explain the following:
    I don't have local access to my server. It's hosted by a company run by a friend of mine, he installed the Ubuntu as a VMWare vm, and I use ssh to access it for any purpose. Of course, now it also run Apache, and I can access it through http (if I don't block it with shorewall of course), but I don't have local access to the box.
    So, if I telnet to localhost in my ssh session, that works fine, unless I specify a port number, in which case I get the message "Unable to connect to remote host: Connection refused". I tried with the actual ip address and localhost, same result.
    I can not telnet in, on any port, from the same location I use ssh. Using putty, it never connects, the window just closes without any messages.
    I suppose this is not really related to the forum topic, but rather about general telnet(d) setup. But my testing stops at this point until I fix it...
    I think you managed to solve most of these by your follow up post afterwards, but to clarify to others in the future:

    Local physical access is not an issue, when I say locally I mean in a shell session on the mail server. Whether that is via SSH or login screen, is irrelevant to me.

    Secondly when I mean telnetting it has nothing to do with telnetd. You are simple testing if the ports are open, and you can send SMTP/IMAP commands via telnet on those ports.

    And firstly when testing you need to do this locally. Then external ISP blocking and (usually) firewall issues are irrelevant. If no reply or connectio refused, then basically that service (postfix or whatever) is not running.

    Once local telneting responds okay to everything. Then you can start telnetting remotely. This will then test your firewall and any ISP blocking of ports.
    Ivar (

  7. #227
    Join Date
    Apr 2005

    Red face Re: Howto: set up a mail server in Ubuntu

    Quote Originally Posted by CaptainMorgan View Post
    Flurdy, this is a superb tutorial- the amount of depth you go into is phenomenal. Thank you for your hard work.

    I had a similar issue as another fellow upon the basic setup portion and then the testing of it- I get "..connection refused." upon attempting to telnet to it, both locally and remotely. Unless I missed something, is it possible my ISP is blocking the port completely? I'll probably make a call to them on Monday but I wanted to try this tutorial out this weekend and hopefully get some replies and/or do more research... and besides, I thought relay_hosts would solve the blocked port issue... unless I have it confused. Any thoughts?

    EDIT 1
    Also, it is wise to be doing this on a development/serving rig? My server runs more than a few websites(virtually), but maybe because of load I'm thinking I should use a spare older system I have to be solely a mail server... google searching for "benefits of a mail server" and different variations turned up commercial avenues; not what I'm looking for...

    EDIT 2
    Ok, so I called Comcast and was told to use 587, so I opened up that port on the router and I still received "....connection refused." Back to the drawing board I guess... unless anyone has any suggestions...

    Good to hear you find the howto usefull!

    As mentioned in my previous post, regarding testing via telnet and ports: If it is rejected locally then it is you setup that is wrong, not the ISP. If works locally but not remotely, then either your firewall or the ISP is at fault.

    Relay host does not solve blocked incomming port. It solves blocked outgoing ports, or use of backup mx for relaying/backup.

    Regarding your 1st edit. How you split your servers up is down to your load, preferences and desire to have seperation of concerns.

    Obviously it would be nice to have seperate machines/instance for each service. That way things are scalable and more secure. But usually it is not affordable. You can try it on the same server and see if it is affected by performance. I would think you have to have quite a few hundreds/thousends of users before that becomes an issue.

    .. right, think ive used by forum credits for this month...
    Ivar (

  8. #228
    Join Date
    May 2009

    Re: Howto: set up a mail server in Ubuntu

    Last edited by p1nkrubb3rd1ld0; June 3rd, 2009 at 05:40 PM.

  9. #229
    Join Date
    Jun 2009

    Question Re: Howto: set up a mail server in Ubuntu

    thanks to all people that contribute to this forum..

    I have a simple question, sorry if Im not to much expert...

    is this server configuration let me send email to off-sites? i mean server on internet gmail or hotmail?

    thanks i really appreciate your help. my email is if you want to writte.

  10. #230
    Join Date
    Nov 2007

    Re: Howto: set up a mail server in Ubuntu

    Hello.. I relly enjoyed doing that tutorial, since its well written, and working nearley perfect.
    There is one little typo, it says to start /etc/init.d/shorewall start, and if it works, edit the /etc/shorewall to Startup yes. But it should be the other way round, shorewall wont start, if the Startupflag has not been set to Yes.

    Also I really really like to know, how to use procmail with this setup, and i tried to google for it and add it on my own, but up to now i failed.. there are 7 or 8 requests in this thread on how to do this, but no answers.. so if someone could PLEASE answer this, it would help a lot of people.


Page 23 of 51 FirstFirst ... 13212223242533 ... LastLast


Posting Permissions

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