Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Not so long ago I did setup my development server on vmware. Currently I'm using ubuntu server. Yesterday when I was trying somethings with php mail() function it didn't work. I got curious. Well for one I went to google. Okey. So I need sendmail program. Then I edited php5/apache2/php.ini file. Set path to sendmail -t -i and restarted apache2 server. Great mail is sent, but nothing was received.

So a coworker said, that I also need a mail server. So now there's a question, what would be the best choice if there is such.

Read this article Setup ubuntu server to send mail(). Can't say much. Would like to hear other opinions if there are any.

Thanks a lot.

share|improve this question

closed as not constructive by Sven, gravyface, jscott, Cakemox, MDMarra Apr 23 '11 at 14:07

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Can you explain what you're trying send via email? ie. outbound only, various website notices, password reminders, registration confirmation, etc.? If you're sending out as, are you also expecting to receive replies to on the same server, or is there another authoritative mail server somewhere else? – gravyface Apr 22 '11 at 14:09
Currently I'm on local server and I'm trying to create error reporting for me. It should be in my understaing only outbound, but later on same code will go in production. – Eugene Apr 22 '11 at 17:01
Can you answer my comment in greater detail please? There's many different ways you can configure a Mail Transfer Agent (MTA) like Postfix, qmail, exim, etc. – gravyface Apr 22 '11 at 17:06
@gravyface I don't expect to receive replies. Is this what you asked about? – Eugene Apr 22 '11 at 17:15
up vote 1 down vote accepted

Not really clear from the question whether or not you already have a mail service set up somewhere to receive these emails. I'm going to assume that your organization has one or that you're sending it to Gmail/Yahoo/Whatever.

We've had very good results with the default Ubuntu exim4 on servers that can simply forward their email elsewhere for safekeeping. Our customer-facing LTSP servers only use it for crontab'd script output and Logwatch.

We use Exim on those forwarding boxes because that's what Ubuntu installs by default with mailutils. Running dpkg-reconfigure exim4-config and it's a mere 30 seconds of configuration work to point it at the main server.

easy peasy.

share|improve this answer
Any example(exim4)? Because currently all examples from internet, that I found don't help. Current config is Oracle VirtualBox and Ubuntu 12.04.02 LTS. Maybe something is blocking in background? – Eugene Jul 8 '13 at 15:15

I won't call it the best, but I like postfix a lot... It is powerful and easy to configure, which is important for security purposes. When it installs, you will get an alias to it as sendmail, so scripts that work with sendmail should be fine under a postfix install.

UBUNTU / DEBIAN TUTORIAL for outbound mail with local delivery:

(as root)

aptitude install postfix
# OR, if already installed....
dpkg-reconfigure postfix
# Select "Internet host".
# Accept defaults
echo "a test from me" | mailx -s "postfix test" you@someemail.local

If your ISP blocks port 25 outbound, configure relayhost = <hostname_of_your_isp_mailserver> in /etc/postfix/ and restart postfix.

Older linux admins tend to use mail, but Ubuntu has renamed mail as mailx

share|improve this answer
Okey. So I guess, that from all of this, I need only this and it should be enough to get it up and running? – Eugene Apr 22 '11 at 10:46
@Eugene, That tutorial sets you up for inbound and outbound mail... If all you want is outbound mail, it asks you to do too much work. – Mike Pennington Apr 22 '11 at 10:58
@Mike Pennington no worries. Thanks a lot. I won't just yet set your answer as the answer. Hope to here some other opinions. But really thanks. – Eugene Apr 22 '11 at 11:11
@Eugene, if you still have sendmail running, I would disable that while you figure this out. If you have a misconfigured mail server, it might be operating as an open relay. – Mike Pennington Apr 22 '11 at 11:15
@Mike I did as you proposed sudo /etc/init.d/sendmail stop and also after light reading sudo update-rc.d sendmail disable. Also did most of the things written here, but that didn't help either. Mail isn't still comming. – Eugene Apr 22 '11 at 14:11

You want to be able to receive email? Then you need something that will accept email into a mail box. Although this is for Debian, there isn't much difference between it and Ubuntu. It includes a full setup of Postfix and Courier.

Setup Mail server

I find that HowToForge has many great setup guides for the Linux community.

There are other equally good SMTP and MAilStores, but this is the better supported setup from the Ubuntu community. Other SMTP servers include Exim and Sendmail. Another MailStore includes Dovecot.

share|improve this answer

I've asked for more details, but I'm going to bite here:

For most Web applications/sites I setup that need to send mail (and again, this isn't necessarily the best way to scale, but my stuff is usually low-load with < 100 concurrent users), I use Postfix on the same box as Apache/PHP.

Because I'm usually dealing with a domain that already has MX records and an authoritative mail server somewhere else, I'll either relay it through that authoritative mail server as a smarthost (usually the easiest method) or set it to send outbound only directly and make sure that the SPF records are updated accordingly and that the public IP address I'm (usually) NAT'ing out as has reverse DNS setup.

If you do end up sending it directly, make sure your banner that's displayed from Postfix has and that you have an A record setup that resolves to the public IP that Postfix is listening on. This shouldn't be necessary, but there's alot of odd anti-spam vigilance out there. I'd also setup and as well; these can be aliases/forwarders to your real email address, but again, I've seen some mail servers try to reconnect and issue a rcpt to from the address that mail is sent as in the header and if it doesn't exist, you'll be black/graylisted.

If you don't have an authoritative mail server, you could setup Postfix and Dovecot for IMAP support, but you'll likely have an easier/more reliable experience setting up Google Apps for your Domain for free and relaying mail off of their servers. As long as you don't plan on sending massive amounts of mail, this works really well and gives you a nice interface for adding email addresses.

Note: I'm finding that increasingly receiving mail servers/anti-spam configurations are setup to drop SMTP traffic originating from Amazon's EC2 block and other commodity hosting providers (HostGator, Dreamhost, etc.), so again, setting up a secure relay to your authoritative mail server is likely the best option.

share|improve this answer

Not saying that it is the "best" but I like qmail a lot, espeacilly for its security and modularity. qmail is built in the Unix way: one small task is handled by a simple process and ali tais processes interact with each other.

Hope this helps!

share|improve this answer

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