Phine Solutions web work notes

Configure sendmail to work with Gmail smtp relay

Filed under: server setup by 1.618 — November 12, 2008 9:25 pm

Ok this one was really a thinker. I spent at least 5 hours to get this to work and finally I was able to use Sendmail to relay through my Gmail account.

A little background:

I have a Linux VPS with CentOS installed. The only email MTA is the default Sendmail. Everything else is pretty much the standard CentOS 4 installation. I don’t intend to use this box as a mail server or any other type of email processor. What I was trying to do is to add some basic capability to send out email from the box using my existing email accounts hosted in Gmail. And I didn’t want to install any additional software such as Postfix for this.

That being said, let me continue to take you down the path that I have gone through, without the stumbling blocks.

My approach was basically: problem -> Google for solutions -> trouble shoot -> Google again. So I found a lot of useful content on the web during the process.

1. Check sendmail

Since gmail uses TLS, you will need to make sure your sendmail is compiled with TLS (for encryption) and SASL (for authentication). This is the command to use to check it:

/usr/sbin/sendmail -d0.1 -bv root

In my case, sendmail does have the necessary compilation flags so I was good. If yours doesn’t, you’ll need to re-compile sendmail and update the binary that is used to start the sendmail service, which is not covered here.

2. Upgrading Cyrus SASL

If your SASL installation doesn’t have the “plain” and “login” lib you will have authentication problem with Gmail. You can see why when you get to the sendmail configuration in the later steps. The common error in the /var/log/maillog is this:

AUTH=client, available mechanisms do not fulfill requirements

It was a vague error and I was so frustrated with it at one point I was ready to give up. However, this article about setting up Postfix with Gmail casted some light and helped me figured out the cause.

The problem is that SASL doesn’t have all the necessary plugins. The “login” and “plain” are the plugins necessary to talk to Gmail smtp. So I had to upgrade SASL to fix the problem. Here is what I did:

$ wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz
$ tar -xzf cyrus-sasl-2.1.21.tar.gz
$ cd cyrus-sasl-2.1.21
$ ./configure
$ make
$ make install

$ mv /usr/lib/sasl2 /usr/lib/sasl2.orig
$ ln -s /usr/local/lib/sasl2 /usr/lib/sasl2

Note: if you have issue installing Cyrus SASL around compiling digestmd5.c, it’s because your compiler is too new. Read here to find out how to patch it.

Since I just switched out the old sasl2 lib without recompiling sendmail, I was concerned sendmail would poop during runtime. Luckily that didn’t happen. Dynamic lib rocks!

3. Generate SSL certificate

I made a directory called certs under /etc/mail. Here are the commands that I used to generate the SSL certificates.

openssl req -new -x509 -keyout cakey.pem -out cacert.pem -days 3650
openssl req -nodes -new -x509 -keyout sendmail.pem -out sendmail.pem -days 3650

Notice I made the certificates good for almost 10 years. I didn’t needed the cacert.pem to be exact.

I also copied /usr/share/ssl/ca-bundle.crt to /ect/mail/certs and included it in the sendmail configuration file. Other wise you’ll see some error like this:

unable to get local issuer certificate

The reason is that the ca bundle file has the Gmail certificate issuer. Although I read it somewhere that email still goes out with this error. Nonetheless, we don’t need to see this if we can fix it.

4. Configure sendmail

With the preparations above we are ready to configure sendmail. I found this tutorial very useful in terms of getting the correct sendmail configurations.

In summary, I have the /etc/mail/auth/client-info looks like this:

AuthInfo:smtp.gmail.com “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”
AuthInfo:smtp.gmail.com:587 “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”

If you use Gmail hosted email with your own domain name, you will have username@hostname.tld in there.

Make sure run:

$ makemap -r hash client-info.db < client-info

and chmod 600 on client info files.

Essential lines in my sendmail.mc

FEATURE(`authinfo’,`hash /etc/mail/auth/client-info.db’)dnl
define(`SMART_HOST’,`smtp.gmail.com’)dnl
define(`RELAY_MAILER_ARGS’, `TCP $h 587′)
define(`ESMTP_MAILER_ARGS’, `TCP $h 587′)

define(`CERT_DIR’, `/etc/mail/certs’)
define(`confCACERT_PATH’, `CERT_DIR’)
define(`confCACERT’, `CERT_DIR/ca-bundle.crt’)
define(`confCRL’, `CERT_DIR/ca-bundle.crt’)
define(`confSERVER_CERT’, `CERT_DIR/sendmail.pem’)
define(`confSERVER_KEY’, `CERT_DIR/sendmail.pem’)
define(`confCLIENT_CERT’, `CERT_DIR/sendmail.pem’)
define(`confCLIENT_KEY’, `CERT_DIR/sendmail.pem’)

define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)

NOTE: Be aware that smart-quotes used in the code examples will not be recognised if pasted into your files! Ensure replacing smart-quotes by regular quotes (see comments below for further detail). – thanks Johnny for the suggestion.

The certificate files are generated/copied from the previous step. I’m no sendmail expert so the configuration lines may not be perfect. But it works. Let me know if you have better settings.

One tip I found very useful is to use the debugging feature. You can set a high log level in the sendmail.mc to see at which step sendmail choked and for what reason.

Also, make sure run “make” or m4 every time you touch the sendmail.mc.

m4 sendmail.mc > sendmail.cf

So that’s pretty much it. I restart the sendmail service and out goes my email.

UPDATE:

Recently I installed Sendmail on a brand new VPS and had hard time get the authentication working. It turned out saslauthd was not running. So a note for new system is to make sure saslauthd has to be up and running (better use chkconfig to make sure it starts up at run level 3) in order to get Sendmail authentication working. This may help resolve some issues in the comments.

56 Comments

  1. Well written, easy to understand directions. Bravo!

    May I make a suggestion that you change $ ./configure to $ ./configure –enable -login
    to make sure the login mechanism is included in the library?

    Thanks for the great helpful article!

    Comment by Bill — January 25, 2009 @ 8:06 pm

  2. Wow, thanks! I was just about going to give up on my similar setup. What drove me nuts is that I had this setup working on a Centos5 box, but on Centos4 I would get the “available mechanisms do not fulfill requirements” error. After reading your post I found out why: Centos4 does not intstall all the SASL plugins by default, but Centos5 does.

    So the solution is even simpler: just “sudo yum install cyrus-sasl-plain”. No need to recompile! :)

    Comment by Stanis — March 30, 2009 @ 1:09 pm

  3. This is a great article. It worked on my VM Redhat linux 9.0.
    easy to the point steps.

    Comment by Rahul — April 12, 2009 @ 4:37 am

  4. Thanks for this article, it helped me a lot to set up sendmail using gmail smtp

    It is maybe obvious, but if someone get the error, he may wonder about :
    - If you copy and past the lines to insert in sendmail.mc , be carefull about the quotes ! You may have to retype them, otherwise getting an error like “ERROR: end of file in string” when executing sendmailconfig
    - also for an unexplained reason, I had at some point to create an empty access.new.db , otherwise, sendmailconfig complained, then I had to run : ‘sudo touch access.new.db && sudo chmod 666 access.new.db && sudo touch access’ , in /etc/mail/

    Then it worked like a charm ! Thanks !

    Comment by Cali — June 12, 2009 @ 5:03 am

  5. Thank’s a lot, it helped me so much!.

    Just to help some newbies (like me), Dont leave any spaces (blanks) before the commands in sendmail.mc, nor leave empty lines in sendmail.mc it will compile ok, but when you restart sendmail it will say something like this:

    554 5.0.0 /etc/mail/sendmail.cf: line 39: unknown configuration line ”

    Regards
    Chanete

    Comment by Chanete — July 7, 2009 @ 7:25 am

  6. AuthInfo:smtp.gmail.com “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”
    AuthInfo:smtp.gmail.com:587 “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”

    didn’t work for me. Change “M:PLAIN” to “M:LOGIN PLAIN” and it works!!

    Comment by Aaron — August 3, 2009 @ 1:43 pm

  7. Very useful guide indeed. I’ve come a logn way with this guide and the gmail server gets verified.

    Log msg: STARTTLS=client, relay=smtp.gmail.com, version=TLSv1/SSLv3, verify=OK, cipher=RC4-MD5, bits=128/128

    However then I get the following error:

    n72Amt1m030791: AUTH=client, available mechanisms do not fulfill requirements
    AUTH=client, relay=smtp.gmail.com, temporary failure, connection abort

    Any idea what might be causing this error? It’s driving me nuts for several days now :-)

    Thanks in advance,
    Robert

    Comment by Robert — August 4, 2009 @ 3:08 pm

  8. Sorry, forgot to mention that I’ve already upgraded the SASL package as described above.

    Comment by Robert — August 4, 2009 @ 3:27 pm

  9. Hi Robert, I’m still suspecting it has something to do with SASLv2 lib. Do you see SASLv2 in the output if you run this command:

    sendmail -d0.1 -bv root

    Comment by 1.618 — August 5, 2009 @ 2:48 pm

  10. I’m getting the following in my mail logs (Service Unavailable) – does anyone have any idea what I’ve done wrong? Thanks so much!!

    Aug 11 21:38:54 LBCLTWEB001 sendmail[7231]: n7BLcsDr007231: from=apache, size=2711, class=0, nrcpts=1, msgid=, relay=apache@localhost
    Aug 11 21:38:54 LBCLTWEB001 sendmail[7232]: n7BLcsEJ007232: from=, size=2948, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=LBCLTWEB001.domainname.com [127.0.0.1]
    Aug 11 21:38:54 LBCLTWEB001 sendmail[7231]: n7BLcsDr007231: to=jasondharper@gmail.com, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32711, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (n7BLcsEJ007232 Message accepted for delivery)
    Aug 11 21:38:55 LBCLTWEB001 sendmail[7234]: STARTTLS=client: file /etc/mail/certs/sendmail.pem unsafe: Group readable file
    Aug 11 21:38:55 LBCLTWEB001 sendmail[7234]: STARTTLS=client, relay=smtp.gmail.com, version=TLSv1/SSLv3, verify=OK, cipher=RC4-MD5, bits=128/128
    Aug 11 21:38:56 LBCLTWEB001 sendmail[7234]: n7BLcsEJ007232: to=, ctladdr= (48/48), delay=00:00:02, xdelay=00:00:02, mailer=relay, pri=122948, relay=smtp.gmail.com [209.85.201.111], dsn=5.0.0, stat=Service unavailable
    Aug 11 21:38:56 LBCLTWEB001 sendmail[7234]: n7BLcsEJ007232: n7BLcuEJ007234: DSN: Service unavailable
    Aug 11 21:38:56 LBCLTWEB001 sendmail[7234]: n7BLcuEJ007234: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=34209, dsn=2.0.0, stat=Sent

    Comment by Jason — August 11, 2009 @ 4:42 pm

  11. Jason, do you have these lines in sendmail.mc?

    define(`RELAY_MAILER_ARGS’, `TCP $h 587′)
    define(`ESMTP_MAILER_ARGS’, `TCP $h 587′)

    It seems you were not connecting to the right ip/port.

    Comment by ren — August 12, 2009 @ 9:52 am

  12. [...] for a long time now and needed to configure my server to relay mail through it. Here’s a nice article that walks you through exactly what needs to be done to configure your sendmail MTA to relay [...]

    Pingback by Configuring Sendmail to relay through Gmail SMTP « The AppGirl Blog — August 18, 2009 @ 4:41 pm

  13. configured in this article and it still it is not working.

    Sep 19 10:41:26 myatt sendmail[24293]: STARTTLS=client, relay=gmail-smtp-msa.l.google.com., version=TLSv1/SSLv3, verify=OK, cipher=RC4-MD5, bits=128/128
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfQma024291: to=, ctladdr= (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120355, relay=gmail-smtp-msa.l.google.com. [72.14.247.111], dsn=5.0.0, stat=Service unavailable
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfQma024291: n8JHfRma024293: DSN: Service unavailable
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfRma024293: to=myattto@gmail.com , delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31588, relay=gmail-smtp-msa.l.google.com., dsn=5.0.0, stat=Service unavailable
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfRma024293: n8JHfRmb024293: return to sender: Service unavailable
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfRmb024293: to=myattto@gmail.com , delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32612, relay=gmail-smtp-msa.l.google.com., dsn=5.0.0, stat=Service unavailable
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfRma024293: Losing ./qfn8JHfRma024293: savemail panic
    Sep 19 10:41:27 myatt sendmail[24293]: n8JHfRma024293: SYSERR(root): savemail: cannot save rejected email anywhere

    thambi

    Comment by Thambi — September 19, 2009 @ 12:52 pm

  14. Thanks a lot for your article!
    I’ve had a similar problem and i’ve found here a great help.

    My solution:
    I need smtp+authentification (on port 587) to send mail via my ISP
    and i’m using mailertable because some domains have to be transported by uucp.
    So I added in my sendmail.mc

    =================================================================
    define(`confAUTH_MECHANISMS’, `PLAIN’)dnl
    FEATURE(`authinfo’,`hash -o /etc/mail/authinfo.db’)dnl

    dnl #———————————————–Default Mailer setup——
    dnl #
    MAILER_DEFINITIONS
    MAILER(`local’)dnl
    MAILER(`smtp’)dnl
    MAILER(`uucp’)dnl # — Denis BRAUSSEN –

    dnl #——————————————–DEDICATED MAILER DEFINITION (SMTP + AUTHINFO PORT 587) —————————
    dnl #
    dnl # THIS MAILER WILL BE USED IN MAILERTABLE
    dnl #
    dnl # CHANGED: ORIGINAL MAILER FLAG F=mDFMuXa0 TO F=mDFMuXae9 (look for “confCON_EXPENSIVE” in cf.README.gz supplied with sendmail)
    dnl #
    define(`ALTSMTP_PORT’,`587′)
    Maltsmtp, P=[IPC], F=mDFMuXae9, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
    T=DNS/RFC822/SMTP,
    A=TCP $h ALTSMTP_PORT
    dnl #
    dnl #
    =================================================================
    Then i created a /etc/mail/authinfo (rw- — — root:smmsp) filled with this line:

    AuthInfo:smtp-auth.sfr.fr “I:UsEr” “P:PaSsWoRd” “R:smtp-auth.sfr.fr” “M:PLAIN”

    (to create the database do: # makemap hash /etc/mail/authinfo < /etc/mail/authinfo )

    and in my /etc/mail/mailertable i have this line:

    #——————————
    . altsmtp:smtp-auth.sfr.fr
    #——————————

    Finally, do *NOT* forget to install libsasl2-modules !
    And all is working fine on my debian 5.03 (lenny)

    Hope this helps,
    regards,
    Denis BRAUSSEN

    Comment by Denis BRAUSSEN — October 27, 2009 @ 6:31 pm

  15. [root@localhost mail]# m4 ./sendmail.mc > ./sendmail.cf
    m4:./sendmail.mc:149: Warning: excess arguments to builtin `define’ ignored
    m4:./sendmail.mc:149: cannot open `/usr/share/sendmail-cf/feature/’authinfo’.m4′: No such file or directory
    m4:./sendmail.mc:150: ERROR: end of file in string

    I am getting these error messages and don’t know what is wrong.

    The line 149 refers to ” FEATURE(‘authinfo’,'hash /etc/mail/auth/client-info.db’)dnl ”
    There is the file, /usr/share/sendmail-cf/feature/authinfo.m4 (without quotation marks), but it says no such file.

    Comment by Rod Rook — November 4, 2009 @ 10:14 pm

  16. The best guaide. All I need!!! Thanks

    Comment by kisloid — November 26, 2009 @ 4:28 pm

  17. Hello

    I have the following message in var/mail/maillog:

    Nov 30 12:52:17 demo sendmail[18466]: alias database /etc/aliases rebuilt by root
    Nov 30 12:52:17 demo sendmail[18466]: /etc/aliases: 76 aliases, longest 10 bytes, 765 bytes total
    Nov 30 12:52:17 demo sendmail[18471]: starting daemon (8.13.8): SMTP+queueing@01:00:00
    Nov 30 12:52:17 demo sendmail[18471]: STARTTLS=server: file /etc/mail/certs/sendmail.pem unsafe: No such file or directory
    Nov 30 12:52:18 demo sm-msp-queue[18479]: starting daemon (8.13.8): queueing@01:00:00
    Nov 30 12:52:30 demo sendmail[18484]: nAUEqUP3018484: from=root, size=64, class=0, nrcpts=1, msgid=, relay=root@localhost
    Nov 30 12:52:30 demo sendmail[18485]: nAUEqUPW018485: from=, size=365, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=demo [127.0.0.1]
    Nov 30 12:52:31 demo sendmail[18484]: nAUEqUP3018484: to=agusberre@hotmail.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30064, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (nAUEqUPW018485 Message accepted for delivery)
    Nov 30 12:52:54 demo sendmail[18489]: STARTTLS=client: file /etc/mail/certs/sendmail.pem unsafe: No such file or directory
    Nov 30 12:52:54 demo sendmail[18489]: STARTTLS=client: file /etc/mail/certs/sendmail.pem unsafe: No such file or directory
    Nov 30 12:52:54 demo sendmail[18489]: STARTTLS=client: file /etc/mail/certs/ca-bundle.crt unsafe: No such file or directory
    Nov 30 12:52:54 demo sendmail[18489]: STARTTLS=client: file /etc/mail/certs/ca-bundle.crt unsafe: No such file or directory
    Nov 30 12:52:54 demo sendmail[18489]: STARTTLS=client, error: load verify locs /etc/mail/certs, /etc/mail/certs/ca-bundle.crt failed: 0

    Anybody can help?
    Thanks!

    Comment by Agustina — November 30, 2009 @ 9:59 am

  18. Thank you! I’ve been working on and off for a week trying to get sendmail SMTPH AUTH relaying to work – this finally got things working. Great post. :)

    Comment by Martin Gerner — March 17, 2010 @ 6:08 am

  19. By the way, some more specific comments: this worked fine on a Debian VM. As noted previously, take extra care if copy-pasting statements from the webpage – quotation marks have a tendency to get scrambled up.

    Comment by Martin Gerner — March 17, 2010 @ 6:09 am

  20. [...] which relay on gmail to sendmail i.e i want use sendmail via gmail i did some changes following http://www.phinesolutions.com/sendma…lay-howto.html but am getting May 20 18:26:13 sparrow sendmail[7156]: o4KCuD1R007156: from=<root@sparrow>, [...]

    Pingback by sendmail with gmail urgent — May 20, 2010 @ 8:09 am

  21. [...] http://www.phinesolutions.com/sendma…lay-howto.html [...]

    Pingback by sendmail with gmail urgent - xBlurb — May 20, 2010 @ 8:46 am

  22. When?I send a mail, I always getting the following error: Server Unavailable in /var/log/syslog.
    I can not send a mail. Please Help me.?

    ###
    I made a client-info in /etc/mail/auth

    AuthInfo:smptp.gmail.com “U:root” “I:myname@gmail.com” “P:XXXXX” “M:LOGIN PLAIN XOAUTH”
    AuthInfo:smptp.gmail.com:587 “U:root” “I:myname@gmail.com” “P:XXXXXX” “M:LOGIN PLAIN XOAUTH”

    ###
    I wrote the sendmail.mc :
    /*—————————————————–*/
    VERSIONID(`$Id: generic-solaris.mc,v 8.13 2001/06/27 21:46:30 gshapiro Exp $’)
    OSTYPE(solaris2)dnl
    DOMAIN(generic)dnl
    FEATURE(`authinfo’,`hash /etc/mail/auth/client-info.db’)dnl
    define(`SMART_HOST’,`smtp.gmail.com’)dnl
    define(`RELAY_MAILER_ARGS’,`TCP $h 587′)
    define(`ESMTP_MAILER_ARGS’,`TCP $h 587′)
    define(`CERT_DIR’, `/etc/mail/certs’)
    define(`confCACERT_PATH’, `CERT_DIR’)
    define(`confCACERT’, `CERT_DIR/ca-bundle.crt’)
    define(`confCRL’, `CERT_DIR/ca-bundle.crt’)
    define(`confSERVER_CERT’, `CERT_DIR/sendmail.pem’)
    define(`confSERVER_KEY’, `CERT_DIR/sendmail.pem’)
    define(`confCLIENT_CERT’, `CERT_DIR/sendmail.pem’)
    define(`confCLIENT_KEY’, `CERT_DIR/sendmail.pem’)

    define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
    TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
    MAILER(local)dnl
    MAILER(smtp)dnl
    /*———————————————–*/

    ####
    So I try a test, I can not sent a mail out !!

    #/usr/ucb/mail -v myname@gmail

    Subject: Test a mail
    What is This?
    .
    ????
    # myname@gmail.com… Connecting to [127.0.0.1] via relay…
    220 scdgrp.co.jp ESMTP Sendmail 2009 cw8.14.4/8.14.4; Wed, 16 Jun 2010 13:14:03 +0900 (JST)
    >>> EHLO scdgrp.co.jp
    250-scdgrp.co.jp Hello localhost [127.0.0.1], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-EXPN
    250-VERB
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
    250-STARTTLS
    250-DELIVERBY
    250 HELP
    >>> VERB
    250 2.0.0 Verbose mode
    >>> STARTTLS
    220 2.0.0 Ready to start TLS
    >>> EHLO scdgrp.co.jp
    250-scdgrp.co.jp Hello localhost [127.0.0.1], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-EXPN
    250-VERB
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
    250-DELIVERBY
    250 HELP
    >>> VERB
    250 2.0.0 Verbose mode
    >>> MAIL From: SIZE=76 AUTH=iacsdb@scdgrp.co.jp
    250 2.1.0 … Sender ok
    >>> RCPT To:
    >>> DATA
    250 2.1.5 … Recipient ok
    354 Enter mail, end with “.” on a line by itself
    >>> .
    050 … Connecting to smtp.gmail.com port 587 via relay…
    050 220 mx.google.com ESMTP a23sm76650385wam.2
    050 >>> EHLO scdgrp.co.jp
    050 250-mx.google.com at your service, [211.126.195.194]
    050 250-SIZE 35651584
    050 250-8BITMIME
    050 250-STARTTLS
    050 250 ENHANCEDSTATUSCODES
    050 >>> STARTTLS
    050 220 2.0.0 Ready to start TLS
    050 >>> EHLO scdgrp.co.jp
    050 250-mx.google.com at your service, [211.126.195.194]
    050 250-SIZE 35651584
    050 250-8BITMIME
    050 250-AUTH LOGIN PLAIN XOAUTH
    050 250 ENHANCEDSTATUSCODES
    050 >>> MAIL From: SIZE=348 AUTH= ??Always empty!!
    050 530-5.5.1 Authentication Required. Learn more at
    050 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 a23sm76650385wam.2
    050 … forward: /export/home/itoki/iacsdb/.forward.scdgrp+: Group writable directory
    050 … forward: /export/home/itoki/iacsdb/.forward+: Group writable directory
    050 … forward: /export/home/itoki/iacsdb/.forward.scdgrp: Group writable directory
    050 … forward: /export/home/itoki/iacsdb/.forward: Group writable directory
    050 … Connecting to local…
    050 … Sent
    250 2.0.0 o5G4E3Gu000266 Message accepted for delivery
    myname@gmail.com… Sent (o5G4E3Gu000266 Message accepted for delivery)
    Closing connection to [127.0.0.1]
    >>> QUIT
    221 2.0.0 scdgrp.co.jp closing connection

    ### /var/log/syslog . I am getting the following :Server Unavailable !!
    Jun 16 13:14:03 IACS_SRV sendmail[266]: [ID 801593 mail.info] o5G4E3Gu000266: from=, size=348, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
    Jun 16 13:14:04 IACS_SRV sendmail[266]: [ID 702911 mail.info] STARTTLS=client, relay=smtp.gmail.com, version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-MD5, bits=128/128
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.info] o5G4E3Gu000266: to=, ctladdr= (5101/500), delay=00:00:02, xdelay=00:00:02, mailer=relay, pri=30348, relay=smtp.gmail.com [74.125.53.109], dsn=5.0.0, stat=Service unavailable
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.warning] o5G4E3Gu000266: forward /export/home/itoki/iacsdb/.forward.scdgrp+: Group writable directory
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.warning] o5G4E3Gu000266: forward /export/home/itoki/iacsdb/.forward+: Group writable directory
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.warning] o5G4E3Gu000266: forward /export/home/itoki/iacsdb/.forward.scdgrp: Group writable directory
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.warning] o5G4E3Gu000266: forward /export/home/itoki/iacsdb/.forward: Group writable directory
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.info] o5G4E3Gu000266: o5G4E3Gv000266: DSN: Service unavailable
    Jun 16 13:14:05 IACS_SRV sendmail[266]: [ID 801593 mail.info] o5G4E3Gv000266: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31372, dsn=2.0.0, stat=Sent
    Jun 16 13:14:05 IACS_SRV sendmail[265]: [ID 801593 mail.info] o5G4E358000265: to=zhang60@gmail.com, ctladdr=iacsdb (5101/500), delay=00:00:02, xdelay=00:00:02, mailer=relay, pri=30076, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o5G4E3Gu000266 Message accepted for delivery)

    Comment by Zhang60 — June 15, 2010 @ 11:28 pm

  23. I am sorry ,I made a big mistake in client-info,

    AuthInfo:smptp.gmail.com “U:root” “I:myname@gmail.com” “P:XXXXX” “M:LOGIN PLAIN XOAUTH”

    not smptp , is smtp .
    Now sendmail is OK.

    Comment by Zhang60 — June 16, 2010 @ 1:14 am

  24. I get the error same to Jason:

    Jun 30 01:21:20 SVR040-04 sendmail[30286]: o5TILKWi030286: from=, size=347, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=SVR040-763.localdomain [127.0.0.1]
    Jun 30 01:21:20 SVR040-04 sendmail[30285]: o5TILKI2030285: to=x, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30043, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o5TILKWi030286 Message accepted for delivery)
    Jun 30 01:21:22 SVR040-04 sendmail[30288]: STARTTLS=client, relay=smtp.gmail.com, version=TLSv1/SSLv3, verify=OK, cipher=RC4-MD5, bits=128/128
    Jun 30 01:21:23 SVR040-04 sendmail[30288]: o5TILKWi030286: to=x, ctladdr= (0/0), delay=00:00:03, xdelay=00:00:03, mailer=relay, pri=120347, relay=smtp.gmail.com [74.125.53.109], dsn=5.0.0, stat=Service unavailable
    Jun 30 01:21:23 SVR040-04 sendmail[30288]: o5TILKWi030286: o5TILNWh030288: DSN: Service unavailable
    Jun 30 01:21:23 SVR040-04 sendmail[30288]: o5TILNWh030288: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31674, dsn=2.0.0, stat=Sent

    and I got no email. Can anyone help me?

    Comment by huyente — June 29, 2010 @ 1:23 pm

  25. Problem solved.

    I have to disable local delivery to get mails in Gmail inbox instead of /var/spool/mail/root, follow Pawel’s post: http://serverfault.com/questions/65365/disable-local-delivery-in-sendmail

    Comment by huyente — June 30, 2010 @ 1:11 am

  26. Great article!saved me lots of times!

    @Rod_Rook you must have the sendmail-cf library missing, use yum or apt-get install sendmail-cf and your problem will be solved.

    Comment by Emad Al-Shihabi — July 15, 2010 @ 1:31 pm

  27. Great article!!! Works well..

    Comment by Levi — August 10, 2010 @ 12:42 pm

  28. Hello!
    Thanks for great article, i use it one times 2 mounths and all works! But now i can’t setup this config on a new server. I’am check identity 10 times, but Connection refused by smtp.gmail.com all the same. May be you can help me with fresh eyes?
    What i see in my sendmail logs:

    Aug 27 23:26:56 london sendmail[19609]: o7RJQulm019609: from=asm, size=39, class=0, nrcpts=1, msgid=, relay=asm@localhost
    Aug 27 23:26:56 london sendmail[19612]: STARTTLS=server, relay=localhost.localdomain [127.0.0.1], version=TLSv1/SSLv3, verify=NO, cipher=DHE-RSA-AES256-SHA, bits=256/256
    Aug 27 23:26:56 london sendmail[19609]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
    Aug 27 23:26:56 london sendmail[19612]: o7RJQuPX019612: from=, size=335, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
    Aug 27 23:26:56 london sendmail[19609]: o7RJQulm019609: to=asm@ailsys.com, ctladdr=asm (505/505), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30039, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o7RJQuPX019612 Message accepted for delivery)
    Aug 27 23:26:56 london sendmail[19614]: o7RJQuPX019612: to=, ctladdr= (505/505), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120335, relay=smtp.gmail.com [74.125.77.109], dsn=4.0.0, stat=Deferred: Connection refused by smtp.gmail.com

    Other (work-well) server :

    Aug 27 23:28:13 barcelona sendmail[22909]: o7RJS1uR022909: from=asm, size=467, class=0, nrcpts=1, msgid=, relay=asm@localhost
    Aug 27 23:28:13 barcelona sendmail[22987]: STARTTLS=server, relay=localhost.localdomain [127.0.0.1], version=TLSv1/SSLv3, verify=NO, cipher=DHE-RSA-AES256-SHA, bits=256/256
    Aug 27 23:28:13 barcelona sendmail[22909]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
    Aug 27 23:28:13 barcelona sendmail[22987]: o7RJSD8h022987: from=, size=749, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
    Aug 27 23:28:13 barcelona sendmail[22909]: o7RJS1uR022909: to=asm, ctladdr=asm (510/510), delay=00:00:12, xdelay=00:00:00, mailer=relay, pri=30467, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o7RJSD8h022987 Message accepted for delivery)
    Aug 27 23:28:13 barcelona sendmail[22988]: o7RJSD8h022987: to=, ctladdr= (510/510), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31056, dsn=2.0.0, stat=Sent

    sendmail.mc differ only in
    [root@london mail]# diff sendmail.mc sendmail.mc.barcelona
    172c172
    MASQUERADE_DOMAIN(barcelona)dnl

    all cert’s in necessary place, i have no other idea in friday evening ;)

    May be you can see what i miss in this problem?

    Thanks!

    Comment by asm — August 27, 2010 @ 2:58 pm

  29. I had an issue on my Debian installation that it was doing authentication by default, even for localhost connections. I commented out the privacy options in sendmail.mc and blocked external SMTP connections, since I’m not using this server for incoming mail.

    No way I would have gotten it to work without your site, thank you thank you thank you for taking the time to post!

    -Tim

    Comment by Tim C. — November 12, 2010 @ 12:24 pm

  30. [...] I need to use something like sendmail to do this – or some other free SMTP relay that gives me better control? I even found a sourceforge [...]

    Pingback by Easiest way to configure local SMTP server to relay through gmail on Windows? Drija — November 18, 2010 @ 12:24 am

  31. [...] I had a look at this sendmail option: http://www.phinesolutions.com/sendmail-gmail-smtp-relay-howto.html [...]

    Pingback by Send emails from Linux via Google SMTP — November 21, 2010 @ 9:36 am

  32. [...] Since I'm out of ideas, I suggest you to follow this tutorial. To create the ssl certificates read #3 here [...]

    Pingback by SMTP AUTH, Sendmail client to Postfix server - Page 3 — December 9, 2010 @ 6:42 pm

  33. define(`RELAY_MAILER_ARGS’, `TCP $h 587?)
    define(`ESMTP_MAILER_ARGS’, `TCP $h 587?)

    you forgot the dnl at the end of these 2 lines. Thanks great walkthrough!!!

    pretty obvious but.. You only need cyrussasl if others will be sending mail through gmail via your machine. not for just relaying localhost straight through gmail.

    Comment by stoggy — December 16, 2010 @ 12:11 am

  34. I followed this guide and some others but just can’t make it work, I’m running a centos 5.5 guest vm, hope someone could help.
    my maillog looks like that:

    Dec 18 21:39:05 centos-drupal sendmail[6400]: alias database /etc/aliases rebuilt by shalom
    Dec 18 21:39:05 centos-drupal sendmail[6400]: /etc/aliases: 76 aliases, longest 10 bytes, 765 bytes total
    Dec 18 21:39:05 centos-drupal sendmail[6405]: starting daemon (8.13.8): SMTP+queueing@01:00:00
    Dec 18 21:39:05 centos-drupal sm-msp-queue[6413]: starting daemon (8.13.8): queueing@01:00:00
    Dec 18 21:39:12 centos-drupal sendmail[6417]: oBIJdC0M006417: from=root, size=45, class=0, nrcpts=1, msgid=, relay=root@localhost
    Dec 18 21:39:12 centos-drupal sendmail[6417]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
    Dec 18 21:39:12 centos-drupal sendmail[6418]: STARTTLS=server, relay=centos-drupal.localdomain [127.0.0.1], version=TLSv1/SSLv3, verify=NO, cipher=DHE-RSA-AES256-SHA, bits=256/256
    Dec 18 21:39:13 centos-drupal sendmail[6418]: oBIJdCNk006418: from=, size=356, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=centos-drupal.localdomain [127.0.0.1]
    Dec 18 21:39:13 centos-drupal sendmail[6417]: oBIJdC0M006417: to=shalom938@gmail.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30045, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (oBIJdCNk006418 Message accepted for delivery)
    Dec 18 21:39:15 centos-drupal sendmail[6420]: STARTTLS=client, relay=smtp.gmail.com, version=TLSv1/SSLv3, verify=OK, cipher=RC4-MD5, bits=128/128
    Dec 18 21:39:15 centos-drupal sendmail[6420]: AUTH=client, relay=smtp.gmail.com [209.85.229.109], authinfo failed
    Dec 18 21:39:16 centos-drupal sendmail[6420]: oBIJdCNk006418: to=, ctladdr= (0/0), delay=00:00:03, xdelay=00:00:03, mailer=relay, pri=120356, relay=smtp.gmail.com [209.85.229.109], dsn=5.0.0, stat=Service unavailable
    Dec 18 21:39:16 centos-drupal sendmail[6420]: oBIJdCNk006418: oBIJdGNj006420: DSN: Service unavailable
    Dec 18 21:39:16 centos-drupal sendmail[6420]: oBIJdGNj006420: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31690, dsn=2.0.0, stat=Sent

    Comment by Shalom K — December 18, 2010 @ 2:48 pm

  35. Good Post.
    My idea of hosting a mail server using a Dynamic-ip did not work. The Dynamic-ip was not allowed to send mails to the outside world.

    So configured gmail smtp+sendmail on opensuse 11.2 to get it going. This was the first post to make things simple.

    Thank you very much

    Comment by Ambar P. — February 6, 2011 @ 6:29 am

  36. I still get the following in /var/log/mail but still the mail gets through. Hopefully the error doesn’t offend gmail to stop sending mails this way.

    sendmail[11031]: STARTTLS=client, relay=smtp.gmail.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-MD5, bits=128/128

    Any ideas??
    Thanks again.

    Comment by Ambar P. — February 6, 2011 @ 6:32 am

  37. I see this in my log to.

    Comment by 1.618 — February 6, 2011 @ 10:37 am

  38. Fantastic article, well written and insightful. I al last got it to work, thanks.

    Comment by Hennie Coetzee — February 20, 2011 @ 5:15 am

  39. [...] http://www.phinesolutions.com/sendmail-gmail-smtp-relay-howto.html [...]

    Pingback by Send mail by Google App own@domain.com not inside mail – Richard Choi — March 1, 2011 @ 12:40 am

  40. For those that keep getting the:

    AUTH=client, relay=smtp.gmail.com [209.85.229.109], authinfo failed

    Your problem is that you copy/pasted the AUTH Section with the quotes into linux and sendmail does not like them.
    Just edit the quotes manually or copy paste from below.

    BAD:
    AuthInfo:smtp.gmail.com “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”

    GOOD:
    AuthInfo:smtp.gmail.com “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”
    AuthInfo:smtp.gmail.com:587 “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”

    Comment by Hick — March 2, 2011 @ 12:07 am

  41. @Hick: Thanks to you, I’ll have dinner at a reasonable hour tonight.

    Comment by Jon — March 5, 2011 @ 10:18 pm

  42. These instructions worked remarkably well for me; I had it working and tested within 20 minutes.

    The biggest problem I had was with the smart quotes in the example configurations. I used this tool to fix them:
    http://dan.hersam.com/tools/smart-quotes.html

    Comment by Simon Arthur — March 25, 2011 @ 8:24 pm

  43. [...] I am trying to configure sendmail to use GMail to send emails. I followed the instructions at http://www.phinesolutions.com/sendma…lay-howto.html but it failed. After I was done with these instructions, I think I "cooked" sendmail… [...]

    Pingback by Sendmail to use Gmail's SMTP to send mail — April 11, 2011 @ 8:39 pm

  44. I keep getting this error:
    Jun 1 21:52:06 bella sendmail[18473]: AUTH=client, relay=smtp.gmail.com [74.125.155.109], authinfo failed
    Jun 1 21:52:06 bella sendmail[18473]: p524q4jm018471: to=, ctladdr= (503/501), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120491, relay=smtp.gmail.com [74.125.155.109], dsn=5.0.0, stat=Service unavailable

    but I fine tooth combed over the instructions.
    [root@bella mail]# sendmail -d0.1 -bv root
    Version 8.14.4
    Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
    MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
    NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
    TCPWRAPPERS USERDB USE_LDAP_INIT

    ============ SYSTEM IDENTITY (after readcf) ============
    (short domain name) $w = localhost6
    (canonical domain name) $j = localhost6.localdomain6
    (subdomain name) $m = localdomain6
    (node name) $k = bella
    ========================================================

    root… deliverable: mailer local, user root

    Comment by Paul — June 2, 2011 @ 12:00 am

  45. [...] ISP. If you cannot find a solution with him, consider using gmail smtp server on port 587 as a relay [...]

    Pingback by stat=Deferred: h.mx.mail.yahoo.com.: No route to host - Page 2 — June 6, 2011 @ 12:44 pm

  46. Why install your own sendmail just to route it back to gmail. The whole object of this exercise should be to avoid your mail going out with the “mail sent on behalf of” tag that makes your email look really amateurish for people receiving your mail in outlook.

    Comment by Joe — July 11, 2011 @ 10:52 pm

  47. This is really a great write-up! It could do with placing a note adjacent to the code-sections though, in the lines of:

    NOTE: Be aware that smart-quotes used in the code examples will not be recognised if pasted into your files! Ensure replacing smart-quotes by regular quotes (see comments below for further detail).

    or similar. I spent a frustrating three hours due to this before finally scrolling down to read some of the comments. But as soon as I realised that, a flawless writeup!

    Comment by Johnny — July 23, 2011 @ 1:26 pm

  48. I followed this and I was getting service unavailable. So I started reading comments. I added the line MAILER(smtp)dnl and everything seemed to work.

    Here is my sendmail.mc
    include(`../m4/cf.m4′)
    VERSIONID(`GMail Support’)dnl
    OSTYPE(`linux’)dnl
    FEATURE(`authinfo’,`hash /etc/mail/client-info.db’)dnl
    define(`SMART_HOST’,`smtp.gmail.com’)dnl
    define(`RELAY_MAILER_ARGS’, `TCP $h 587′)
    define(`ESMTP_MAILER_ARGS’, `TCP $h 587′)
    define(`CERT_DIR’, `/etc/mail/certs’)
    define(`confCACERT_PATH’, `CERT_DIR’)
    define(`confCACERT’, `CERT_DIR/ca-bundle.crt’)
    define(`confCRL’, `CERT_DIR/ca-bundle.crt’)
    define(`confSERVER_CERT’, `CERT_DIR/sendmail.pem’)
    define(`confSERVER_KEY’, `CERT_DIR/sendmail.pem’)
    define(`confCLIENT_CERT’, `CERT_DIR/sendmail.pem’)
    define(`confCLIENT_KEY’, `CERT_DIR/sendmail.pem’)
    define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
    TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
    define(`confAUTH_OPTIONS’, `A’)dnl
    MAILER(smtp)dnl

    I am running Slackware so I copy this to /usr/share/sendmail/cf/cf so that the include line works. Due to the size of cf.m4 and it’s includes, I will leave them out. If you want to see them get a copy of slackware, or browse an online repository, and look for /usr/share/sendmail/cf/m4 which should be in the sendmail package for slackware.

    I will also note that I successfully sent an email without the ca-bundle.cert

    Comment by WrinkledCheese — July 29, 2011 @ 3:01 pm

  49. [...] I need to use something like sendmail to do this – or some other free SMTP relay that gives me better control? I even found a sourceforge [...]

    Pingback by Easiest way to configure local SMTP server to relay through gmail on Windows? - Admins Goodies — August 21, 2011 @ 3:33 am

  50. Hi,
    Thanks a lot for the help…my issue got resolved by following the trail comments…

    Thanks a lot again..

    Comment by vne — August 29, 2011 @ 2:42 am

  51. hi folks,

    iam getting this error, any idea?

    m4:sendmail.mc:176: Warning: excess arguments to builtin `define’ ignored
    m4:sendmail.mc:176: cannot open `/usr/share/sendmail-cf/feature/’authinfo’.m4′: No such file or directory
    *** ERROR: MAILER(smtp) already included

    My config

    FEATURE(‘authinfo’,’hash /etc/mail/client-info.db’)dnl
    define(‘SMART_HOST’,’smtp.gmail.com’)dnl
    define(‘RELAY_MAILER_ARGS’, ‘TCP $h 587?)
    define(‘ESMTP_MAILER_ARGS’, ‘TCP $h 587?)
    define(‘CERT_DIR’, ‘/etc/mail/certs’)
    define(‘confCACERT_PATH’, ‘CERT_DIR’)
    define(‘confCACERT’, ‘CERT_DIR/ca-bundle.crt’)
    define(‘confCRL’, ‘CERT_DIR/ca-bundle.crt’)
    define(‘confSERVER_CERT’, ‘CERT_DIR/sendmail.pem’)
    define(‘confSERVER_KEY’, ‘CERT_DIR/sendmail.pem’)
    define(‘confCLIENT_CERT’, ‘CERT_DIR/sendmail.pem’)
    define(‘confCLIENT_KEY’, ‘CERT_DIR/sendmail.pem’)
    define(‘confAUTH_MECHANISMS’, ‘EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
    TRUST_AUTH_MECH(‘EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)

    Comment by mav3 — August 31, 2011 @ 5:28 am

  52. [...] http://www.phinesolutions.com/sendmail-gmail-smtp-relay-howto.html Like this:LikeBe the first to like this [...]

    Pingback by Gmail SMTP? sendmail ???? ???? « Help Work — October 10, 2011 @ 3:50 am

  53. [...] for a long time now and needed to configure my server to relay mail through it. Here’s a nice article that walks you through exactly what needs to be done to configure your sendmail MTA to relay [...]

    Pingback by Setup sendmail (notifications) for GMAIL SMTP « darryn van tonder — January 3, 2012 @ 11:44 pm

  54. Thank you, thank you, thank you for your tutorial. I have discovered another caveat though.

    If you are using a *brand new* Gmail account you may get the following error in /var/log/maillog:

    relay=smtp.gmail.com, dsn=5.0.0, stat=Service unavailable

    One cause for this error is that you have to log-in at least once into your Gmail account from your browser! This is due to the fact that Google needs you to accept the terms of service.

    After spending half a day tweaking my sendmail configuration I finally bothered to read a “Delivery Status Notification” that bounced back and it was right there in front of my eyes:

    —– Transcript of session follows —–
    … while talking to smtp.gmail.com:
    >>> AUTH dialogue
    <<< 535-5.7.1 Please log in with your web browser and then try again. Learn more
    at
    <<< 535 5.7.1 https://mail.google.com/support/bin/answer.py?answer=78754 cv10sm1
    20709067igc.0

    It never hurts to double check every part of your system!

    Comment by Marco — January 5, 2012 @ 5:04 pm

  55. Thanks-a-mundo for the post.Really thank you! Wonderful.

    Comment by Allan Brinton — January 29, 2012 @ 4:00 am

  56. Hello. I need your help to get this working.I have followed this guide. I am struck here. I am unable to figure it out. Thanks in advance.
    # sendmail -v user@gmail.com
    test mail
    .
    user@gmail.com… Connecting to [127.0.0.1] via relay…
    220 mailserver ESMTP Sendmail 8.14.4/8.14.4/Debian-2ubuntu1; Thu, 9 Feb 2012 23:35:34 +0530; (No UCE/UBE) logging access from: domain.com(OK)-domain.com [127.0.0.1]
    >>> EHLO domain.com
    250-mailserver Hello domain.com [127.0.0.1], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-EXPN
    250-VERB
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
    250-DELIVERBY
    250 HELP
    >>> VERB
    250 2.0.0 Verbose mode
    >>> MAIL From: SIZE=7 AUTH=root@domain.com
    250 2.1.0 … Sender ok
    >>> RCPT To:
    >>> DATA
    250 2.1.5 … Recipient ok
    354 Enter mail, end with “.” on a line by itself
    >>> .
    050 … Connecting to smtp.gmail.com via relay…
    050 220 mx.google.com ESMTP r9sm5865836pbi.6
    050 >>> EHLO mailserver
    050 250-mx.google.com at your service, [144.16.79.25]
    050 250-SIZE 35882577
    050 250-8BITMIME
    050 250-STARTTLS
    050 250 ENHANCEDSTATUSCODES
    050 >>> STARTTLS
    050 220 2.0.0 Ready to start TLS
    050 >>> EHLO mailserver
    050 250-mx.google.com at your service, [144.16.79.25]
    050 250-SIZE 35882577
    050 250-8BITMIME
    050 250-AUTH LOGIN PLAIN XOAUTH
    050 250 ENHANCEDSTATUSCODES
    050 >>> MAIL From: SIZE=285 AUTH=
    050 530-5.5.1 Authentication Required. Learn more at
    050 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 r9sm5865836pbi.6
    050 … Using cached ESMTP connection to smtp.gmail.com via relay…
    050 >>> RSET
    050 250 2.1.5 Flushed r9sm5865836pbi.6
    050 >>> MAIL From:
    050 530-5.5.1 Authentication Required. Learn more at
    050 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 r9sm5865836pbi.6
    050 MAILER-DAEMON… aliased to postmaster
    050 postmaster… aliased to root
    050 postmaster… aliased to root
    050 root… Connecting to local…
    050 root… Deferred: local mailer (/usr/sbin/sensible-mda) exited with EX_TEMPFAIL
    250 2.0.0 q19I5Y90018775 Message accepted for delivery
    user@gmail.com… Sent (q19I5Y90018775 Message accepted for delivery)
    Closing connection to [127.0.0.1]
    >>> QUIT
    221 2.0.0 mailserver closing connection

    Comment by Sameer — February 9, 2012 @ 7:39 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

©phinesolutions.com