I want to send emails from my Debian 6 server. I only want to send. I've followed every set of instructions I can find for Sendmail, Exim4 and Postfix and can not get any working. I tried the SMTP Authentication Support module to send mail through a Gmail account. But then that suddenly stopped working too. The test email that I can send via the module's configuration form works, but trying to send via drupal_mail() fails.

mail -v travis@targetdomain.com reports that the message was accepted for delivery, but the mail never arrives in my inbox. Below is the output. I was thinking that maybe the issue was with the MAIL From: travis@debian, but everything I've tried to change that with is failing as well. I've changed /etc/email-addresses and added a rewrite rule with an f flag to change the from header, to no avail. Anyway, the output:

turibe@servername:~$ mail -v travis@addressdomain.com
Subject: Testing
travis@addressdomain.com... Connecting to [] via relay...
220 example.com ESMTP Sendmail 8.14.3/8.14.3/Debian-9.4; Thu, 30 May 2013 00:53:01 -0700; (No UCE/UBE) logging access from: localhost(OK)-localhost []
>>> EHLO example.com
250-example.com Hello localhost [], pleased to meet you
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<turibe@example.com> SIZE=218 AUTH=turibe@example.com
250 2.1.0 <turibe@example.com>... Sender ok
>>> RCPT To:<travis@addressdomain.com>
>>> DATA
250 2.1.5 <travis@addressdomain.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <travis@addressdomain.com>... Connecting to aspmx.l.google.com. via esmtp...
050 220 mx.google.com ESMTP zb4si24120260obb.80 - gsmtp
050 >>> EHLO example.com
050 250-mx.google.com at your service, [2600:3c00::f03c:91ff:fe70:4335]
050 250-SIZE 35882577
050 250-8BITMIME
050 250-STARTTLS
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO example.com
050 250-mx.google.com at your service, [2600:3c00::f03c:91ff:fe70:4335]
050 250-SIZE 35882577
050 250-8BITMIME
050 >>> MAIL From:<turibe@debian> SIZE=471
050 250 2.1.0 OK zb4si24120260obb.80 - gsmtp
050 >>> RCPT To:<travis@addressdomain.com>
050 >>> DATA
050 250 2.1.5 OK zb4si24120260obb.80 - gsmtp
050 354  Go ahead zb4si24120260obb.80 - gsmtp
050 >>> .
050 250 2.0.0 OK 1369900381 zb4si24120260obb.80 - gsmtp
050 <travis@addressdomain.com>... Sent (OK 1369900381 zb4si24120260obb.80 - gsmtp)
250 2.0.0 r4U7r1kG022811 Message accepted for delivery
travis@addressdomain.com... Sent (r4U7r1kG022811 Message accepted for delivery)
Closing connection to []
>>> QUIT
221 2.0.0 example.com closing connection

I've tried several different addresses. It's driving me crazy. This seems like it should be a fairly simple issue to solve, but nothing I've tried nor anything I can find on the issue is working. I've read so many articles where the author says all he did to send mail was something like apt-get install sendmail and off he went, but none of the same steps are working for me.

Update Before this is asked, I did ensure that all outbound connections were enabled. And indeed, the mail command does appear to successfully connect with GMail.

Update This server is a Linode server, not a home server.

Update I followed this article exactly, and didn't run into any errors at all. Still, no luck sending emails. All I want from life is to be able to send email from my server.

Update I tried this article as well - no luck. /var/log/exim4/mainlog records after a few minutes that the message is frozen.

  • Have you checked you "spam" box on your gmail account?
    – mdpc
    May 30, 2013 at 21:16
  • Yes, I have. That was one of the first things I did. Sadly, there was nothing there either.
    – tvanc
    May 30, 2013 at 21:21
  • 2
    If you were to use a working MAIL FROM-address, it's likely you'd be getting a bounce to that address with just the information you need to figure the problem out.
    – Jenny D
    May 31, 2013 at 8:19
  • @jennyd, Which one is being used? At the top of the output it says >>> MAIL From:<turibe@example.com> SIZE=218 AUTH=turibe@example.com, but further down it says 050 >>> MAIL From:<turibe@debian> SIZE=471 I just created the former email address and hope to receive the bounces there. I know it can take a while. If it's using the latter, do you know how to change that? I've tried changing the rewrite rules to no avail.
    – tvanc
    May 31, 2013 at 19:17

2 Answers 2


You should configure the server to use a smarthost as a relay. Normally, your ISP will provide a relay for you to use.

If you want to send directly to the Internet you need fixed IP address with a PTR record pointing to an A record which returns the address. Otherwise many servers will block you. You should also have an MX record for the domain you are sending from that points to your mail servers name. SPF record for both domains can help unless they forbid your server from sending for that domain.

Spamhaus lists many of the dynamic IP address ranges and you will get blocked if your IP address is listed there. If you are listed in other blacklists you are also likely to be blocked.

Just because your mail server has accepted the message for delivery, does not mean that your mail server will be able to deliver it. Try the mailq command to see if your server is still trying to send the message. Email is store and forward, and your server may take up to a day or so to tell you it is having problems delivering the mail.

EDIT: The easiest solution is to use the command dpkg-reconfigure exim4-config and select the smarthost option. Use your provider's email relay and things should work well. Make sure you use a valid sender email address. While GMail may work, it is extra effort to setup the required authentication, and they may limit the amount of email you send if your don't have a paid account.

If you want to run your own mail server you could start with my article on Running and Email Server. You may also want to review my Email Policy document and the documents it lists. I have several other posts related to email. My server of choice is Exim.

  • My server is on Linode. Perhaps I should have mentioned that, but I didn't realize anyone would think this was a home server. I've read soooo many articles on how to get sendmail working, and none of them have mentioned doing any DNS settings at all. There must be something else I'm missing. I ran mailq, and it reported that there were no queued messages.
    – tvanc
    May 31, 2013 at 7:15
  • I tried configuring exim4 to send through my Google Apps account as instructed in this article. Still no luck. Can you point me to any resources on configuring the DNS records as you've suggested? It still seems crazy to me that I never would have seen anything about making those changes, but I'm willing to try it.
    – tvanc
    Jun 1, 2013 at 22:17
  • I've added edits which may help get you on track.
    – BillThor
    Jun 7, 2013 at 0:43
  • I ended up finally getting the emails working, and the issue was that I was using what apparently - contrary to the instructions of every article I read on the matter - the wrong address for the Gmail SMTP server. I do have a paid Google Apps account, so this is a good solution for me.
    – tvanc
    Jun 8, 2013 at 4:39

I finally got the emails working by following this article: http://wiki.debian.org/GmailAndExim4

The key difference appears to be this line in /etc/exim4/passwd.client: *.google.com:SMTPAccountName@gmail.com:y0uRpaSsw0RD

Once I added it, my emails started working. Previously, I had been using smtp.gmail.com instead of *.google.com. I tried removing that line in favor of the smtp.gmail.com line to verify that that had been the fix, and indeed it was, as I could not send emails without the *.google.com line.

Since I do have a paid Google Apps account, using Google as the smarthost is a good solution for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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