sendmail help

I'm trying to get sendmail set up in my debian install. I used Apt to install Apache and PHP - how would I use to to install sendmail and incorporate it into PHP?

14 Replies

Why in the world are you punishing yourself with sendmail?

Well what other options are available?


Well what other options are available?

If you're using the Debian disk image from Linode, you probably already have exim4 installed.

Or you can install postfix, currently the most popular MTA.

apt-get install postfix

Whats MTA mean?

And if I have exim4 how would I tell? And if so how would I incorporate it into my PHP?

MTA means mail transfer agent. It's a program that takes care of receiving and sending emails to and from your server. Sendmail, exim4, postfix, etc. are different kinds of MTA's. You only need one of them.

In order to tell if exim4 (or postfix, or anything else) is installed, try

apt-get install exim4

If it tells you that exim4 is already installed, then it is. If not, the command above will automatically install it for you. Same goes for sendmail/postfix/etc. Just replace the last word with the name of the program you want to install.

What do you mean, incorporating mail into PHP? If you mean sending welcome emails, password reminders, etc. from your blog/forum software, all you need to do is to install the MTA, and PHP takes care of the rest. There's no need to manually put the two together. On Debian, these things just work out of the box.

If you do install an MTA on your server, and you're only going to use it for sending emails from PHP, you must make sure that your port 25 is unreachable from the outside. Otherwise, bad people could send spam using your server!

I installed exim4 and PHP still wont send emails

Did you update sendmail_path in your php.ini? it points to /usr/sbin/sendmail by default.

The simple fix is to create a symbolic link.

ln -s /usr/sbin/sendmail /usr/sbin/exim

Then you won't need to update the php.ini. I'm guessing on the exim binary path as I don't use exim.


Did you update sendmail_path in your php.ini? it points to /usr/sbin/sendmail by default.

The simple fix is to create a symbolic link.

ln -s /usr/sbin/sendmail /usr/sbin/exim

Then you won't need to update the php.ini. I'm guessing on the exim binary path as I don't use exim.

exim4 already has '/usr/sbin/sendmail' - all MTA packages install it for compatibility reasons.

> I installed exim4 and PHP still wont send emails

Heard of a log report? What errors, etc. You may need to enable debugging in your PHP script.

2009-01-07 09:01:22 1LKYyI-0007b9-Te <= U=www-data P=local S=1346 2009-01-07 09:01:23 1LKYyI-0007b9-Te ** Unrouteable address 2009-01-07 09:01:23 1LKYyJ-0007bB-2q <= <> R=1LKYyI-0007b9-Te U=Debian-exim P=local S=2175 2009-01-07 09:01:23 1LKYyI-0007b9-Te Completed 2009-01-07 09:01:23 1LKYyJ-0007bB-2q => www-data <>R=local_user T=mail_spool 2009-01-07 09:01:23 1LKYyJ-0007bB-2q Completed</>

So you're trying to send an email to, and exim is telling you that it has no idea where to send that email.

1. The public DNS records for shows that the one and only MX record for your domain is Is this the email hosting company that you're using? If so, is the correct MX record to be using?

2. Does your server think that its hostname is The first line of your log suggests that it does. In that case, exim will think that is a local email address. It will try to deliver the email to the mailbox of a local user named zach. Not what you want! (I'm assuming that you don't want to use your Linode to read emails, since you're outsourcing your email to another company.) Change your hostname to a subdomain and try again. You'll also need to go through exim's configuration files to update the hostname.

If it helps, this was his original request:

Basically trying to forward email to his exchange servers.

Ok, I changed my hostname to

The latest error:

2009-01-07 12:42:29 1LKcQH-0000Sc-7I <= U=www-data P=local S=574
2009-01-07 12:42:29 1LKcQH-0000Sc-7I [] Connection refused
2009-01-07 12:42:29 1LKcQH-0000Sc-7I ** R=dnslookup T=remote_smtp: SMTP error from remote mail server after HELO localhost: host []: 501 5.5.4$
2009-01-07 12:42:29 1LKcQH-0000Sf-Us <= <> R=1LKcQH-0000Sc-7I U=Debian-exim P=local S=1546
2009-01-07 12:42:30 1LKcQH-0000Sc-7I Completed
2009-01-07 12:42:30 1LKcQH-0000Sf-Us ** Unrouteable address
2009-01-07 12:42:30 1LKcQH-0000Sf-Us Frozen (delivery error message)

Looks like a DNS lookup issue. Do you have pointed to your linode's IP? Need a DNS entry in zone for server1…

As Deviation said, your DNS is not setup correctly. See

$ dig

; <<>> DiG 9.3.4-P1.1 <<>>
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 61332
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;    IN      A

;; AUTHORITY SECTION:     3600    IN      SOA     cluster1node1.internal.digitalex 2006122165 900 600 3600 3600

;; Query time: 369 msec
;; WHEN: Wed Jan  7 19:40:44 2009
;; MSG SIZE  rcvd: 112

i.e. the host can't be resolved


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct