1

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.

4
  • 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 yourdomain.com, are you also expecting to receive replies to yourdomain.com on the same server, or is there another authoritative mail server somewhere else?
    – gravyface
    Apr 22, 2011 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, 2011 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, 2011 at 17:06
  • @gravyface I don't expect to receive replies. Is this what you asked about?
    – Eugene
    Apr 22, 2011 at 17:15

5 Answers 5

1

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.

1
  • 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, 2013 at 15:15
2

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" [email protected]

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

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

22
  • Okey. So I guess, that from all of this help.ubuntu.com/community/MailServer, I need only this help.ubuntu.com/community/Postfix and it should be enough to get it up and running?
    – Eugene
    Apr 22, 2011 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. Apr 22, 2011 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, 2011 at 11:11
  • 1
    @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. Apr 22, 2011 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 help.ubuntu.com/community/Postfix, but that didn't help either. Mail isn't still comming.
    – Eugene
    Apr 22, 2011 at 14:11
0

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.

0

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 mail.yourdomain.com 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 [email protected] and [email protected] 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.

0

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!

Not the answer you're looking for? Browse other questions tagged .