Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am setting up a mail server, on Ubuntu, based on: https://help.ubuntu.com/community/Postfix

Currently, I can both send and receive email from the server. However, attempts to send email through SMTP from gmail fail with a bad authentication. I've verified my password, ensured that the port is open, and am able to telnet to the IP and port.

Telnet output (from remote host)

Computer:~ Louis$ telnet mail.mysite.com 587
Trying 71.66.218.124...
Connected to mail.mysite.com (71.66.218.124).
Escape character is '^]'.
220 mail.mysite.com ESMTP Postfix
ehlo mail.mysite.com
250-mail.mysite.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH DIGEST-MD5 NTLM CRAM-MD5 PLAIN LOGIN
250-AUTH=DIGEST-MD5 NTLM CRAM-MD5 PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

And, testing my login information:

sudo testsaslauthd -u jon -p ********
0: OK "Success."

And currently listening ports:

netstat -ln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN     
tcp6       0      0 :::587                  :::*                    LISTEN     
tcp6       0      0 :::110                  :::*                    LISTEN     
tcp6       0      0 :::143                  :::*                    LISTEN     
tcp6       0      0 :::4949                 :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::25                   :::*                    LISTEN

Any idea why I cannot remotely configure my SMTP to send email?

EDIT

I am preferential to gmail's interface, and would like to aggregate all of my mail on one online service. I can add my POP3 account on gmail (settings > accounts > Add a POP3 Mail Account Of Your Own). After successfully authenticating with my server, I am asked if I'd like to send email through my servers smtp, to which I say yes. When I try and login, I get the following message:

Authentication failed. Please check your username/password. [Server response: 535 5.7.8 Error: authentication failed: authentication failure code(535) ]

I should note, this is not a gmail problem - I cannot authenticate from ANY device or application over smtp. However, I can authenticate using the tools on the server, and over telnet . . .

EDIT 2

Errors from /var/log/mail.log

Feb 2 14:52:42 Mysite postfix/smtpd[16527]: connect from mail-ea0-f76.google.com[102.85.215.76] Feb 2 14:52:43 Mysite postfix/smtpd[16527]: Anonymous TLS connection established from mail-ea0-f76.google.com[102.85.215.76]: TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits) Feb 2 14:52:43 Mysite postfix/smtpd[16527]: warning: SASL authentication failure: Password verification failed Feb 2 14:52:43 Mysite postfix/smtpd[16527]: warning: mail-ea0-f76.google.com[102.85.215.76]: SASL PLAIN authentication failed: authentication failure Feb 2 14:52:43 Mysite postfix/smtpd[16527]: disconnect from mail-ea0-f76.google.com[102.85.215.76]

EDIT 3 Here's my /etc/postfix/main.cf as requested.

mydomain = mysite.com
biff = no
append_dot_mydomain = no
smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/smtpd.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
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name 
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = mysite.localdomain, mysite, localhost.localdomain, localhost, mail.mysite.com, mysite.com
relayhost = 
mynetworks = 127.0.0.0/8
inet_interfaces = all
mailbox_size_limit = 0
recipient_delimiter = +
myorigin = mysite.com
inet_protocols = all
smtpd_sasl_local_domain = 
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_auth_only = no
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
myhostname = mail.mysite.com 
home_mailbox = Maildir/
mailbox_command = 
virtual_alias_domains = mysite.com
virtual_alias_maps = hash:/etc/postfix/virtual
share|improve this question
    
How does Gmail fit into the picture? What is the actual error message and what is providing it? –  mgorven Jan 31 '13 at 22:18
    
In gmail you can add an external account. Since I have several accounts, and prefer gmail's interface to other online options, I'd like to also add my site's email account to my gmail account. I've edited my post to reflect this information. –  Louis Feb 1 '13 at 0:29
    
What do the server logs say? –  mgorven Feb 1 '13 at 18:55
    
Edited to show the error in the logs. –  Louis Feb 2 '13 at 20:57

3 Answers 3

up vote 1 down vote accepted
+50

SASL Authentication Check List

Base on question and comments, sasl may not be setup correctly. Following check list is created base on Ubunut Guide provided in question.

  1. Check file/etc/postfix/sasl/smtpd.conf, should be like following

    pwcheck_method: saslauthd
    mech_list: plain login
    
  2. Check libsasl installed

    dpkg -l | grep sasl
    

    Should have the following (version number may differ)

    ii  libsasl2-2           2.1.25.dfsg1-4    Cyrus SASL - authentication abstraction library
    ii  libsasl2-modules     2.1.25.dfsg1-4    Cyrus SASL - pluggable authentication modules
    ii  sasl2-bin            2.1.25.dfsg1-4    Cyrus SASL - administration programs for SASL users database
    
  3. Check saslauthd is running

    ps -ef | grep sasl
    
  4. Check saslauthd PWDIR

    grep PWDIR /etc/default/saslauthd
    

    Output should be

    PWDIR="/var/spool/postfix/var/run/saslauthd"
    

Postfix submission/587

  1. /etc/postfix/master.cf

    The Ubuntu guide only un-comment one line

    submission inet n       -       -       -       -       smtpd
    

    Try ucomment the whole section, including the options following it

    submission inet n       -       -       -       -       smtpd
      -o smtpd_tls_security_level=encrypt
      -o smtpd_sasl_auth_enable=yes
      -o smtpd_client_restrictions=permit_sasl_authenticated,reject
      -o milter_macro_daemon_name=ORIGINATING
    

    Then restart postfix

    sudo service postfix restart
    
  2. Double check your smtp login name

    Since the guide is not using virtual user, your smtp login name should be joe only, not joe@mysite.com. Double check email clients on your deivces/computers/webservices(gmail) are NOT using your email address as smtp login name. (Many do that for you. You will have to manually change it if so.)

  3. Remove Password Map

    I believe you are authenticating against local Linux account, not virtual user. Remove the following lines in /etc/postfix/main.cf

    # password maps will not work. Customer must provide credentials
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    
share|improve this answer
    
Nope, this did not work. –  Louis Feb 5 '13 at 1:35
    
Please add /etc/postfix/main.cf in your question. –  John Siu Feb 5 '13 at 1:43
    
Added under edit #3. –  Louis Feb 5 '13 at 4:32
    
Check #3. I believe you are using local linux user, not virtual user. –  John Siu Feb 5 '13 at 14:30
    
BTW, is your server receiving incoming email at all? –  John Siu Feb 5 '13 at 14:57

You mention that you are trying to send the mail through SMTP from Gmail. External public mail servers delivering mail to your domain typically will not authenticate to your smtpd (certainly, they will not pass the credentials you logged into gmail with!). Your SMTP server should permit relaying to addresses within your domain without authentication (so incoming mail can be received), and require authentication for "outgoing" mail (that being relayed to other domains) only.

From your comment, it appears you are requiring authentication for all relaying. Gmail has no credential to provide, so of course it will be unable to authenticate to your mailserver.

share|improve this answer
    
nope, 587 is not encrypted by default, STARTTLS is perfectly ok on that port. you probably confused with 465 –  Gryphius Jan 31 '13 at 7:38
    
I've added my account (jon@mysite.com) to gmail, so that I can both fetch emails and send them through my domain. I can successfully fetch the emails using POP or IMAP, but I cannot relay emails from gmail, through my server (I get the authentication error). It's also important to note that I'm not using my gmail credentials to attempt to login. With that said, Gryphius and you have differing opinions. Who's correct, and what do you recommend I do next? –  Louis Jan 31 '13 at 18:01
    
He is right about the use of 587. However, you must not require authentication for incoming messages bound for local delivery. Think about this. –  Falcon Momot Feb 1 '13 at 6:31
    
Not concerned with local delivery. I need the smtp to relay my messages as outgoing so I need to authenticate. –  Louis Feb 1 '13 at 20:51

Another route to try is use port 465 and smtps.

http://ubuntuforums.org/showthread.php?t=1946910

share|improve this answer
    
I don't have the mentioned configuration files, as they appear to be for Mutt(?). –  Louis Feb 5 '13 at 2:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.