Setting Up postfix to send outgoing mail on ubuntu

I don't know why but this is one of those things that I find extremely annoying to set up. Mainly because it often requires installing a full-blown MTA to do a much simpler job than it was designed to do. Unfortunately, ssmtp and exim, the only simpler ones, often suck (especially ssmtp, which even the maintainer gave up on). What follows is how I got postfix working on my Ubuntu Feisty machine (should work on more recent version of Ubuntu as well):

sudo apt-get install postfix
sudo dpkg-reconfigure postfix

Here are the options to answer in order:

"satellite" (when given the list of configuration styles)
<your normal user> (where to forward root's mail to)
<your host name>
<your ISP's smtp server>
accept default (when asked what other domains to accept mail from)
No (default is no synchronous updates on mail queue)
127.0.0.0/8 (accept default unless you know what you are doing)
0 (mailbox limit)
+ (default)
all (default)

Reload or restart postfix, then do some testing:

sudo apt-get install mailx
echo test |mail -s "test mail sent to external" <a href="mailto:me@gmail.com">me@gmail.com</a>
echo test |mail -s "test mail sent to normal user" <normal user name>
echo test |mail -s "test mail sent to root" root

You should get an email to your external address. And if you run

mail

you should see 2 emails there for you, one that was sent to root (but was directed to you, see /etc/aliases for why) and the other that was sent to you.

To have those mails sent to an external address instead (like your me@gmail.com address) do the following:

echo me@gmail.com > ~/.forward

Update (2007-07-19): When I changed ISPs, my new ISP did not like my From: address being david@centurion (I just named it after the case model). So I had to do the following. Add this to /etc/postfix/main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

Add this to /etc/postfix/generic:

@centurion      <a href="mailto:david@telus.net">david@telus.net</a>

I just made up an email address there to make it happy.
Don't forget to run sudo postmap /etc/postfix/generic

Comments

I've got an error on the first message. The message is't delivered and I found a mail in my local mailbox with the following error message:

Diagnostic-Code: smtp; 554 5.7.1 : Sender
address rejected: Access denied

Any idea?

Thanks in advance

I needed to thank you for this extraordinary read!! I unquestionably appreciating each and every piece of it I have you bookmarked to look at new stuff you post.FIFA 18 Gold Buying

The writer of this post has some great writing skills and that is shown here. I think that this writer can go really high places if the writer continues to give us such amazing quality posts as this one. voyance gratuite

A particularly wonderful blog zone. We are really grateful for your blog an area. You will discover a ton of frameworks in the wake of going by your post.stresser

Gracias por este material. He tenido la intención de pedirle que dé un poco más de material sobre este tema para que pueda terminar mi trabajo lo antes posible. Y ahora, me has dado el material que necesitaba. Gracias! hechizos de amor

If you set out to make me think today; mission accomplished! I really like your writing style and how you express your ideas. Thank you.!
voyance par telephone

Much obliged for sharing us about this upgrade. Trust you won't get tired on making posts as useful as this.!
roofing service

You mentioned in your postifx article that you found a fix for the address rejected issues with the mail relay. would you mind posting it?

I believe I gave the solution in the post:

Add this to /etc/postfix/main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

Add this to /etc/postfix/generic:

@centurion      <a href="mailto:david@telus.net">david@telus.net</a>

I just made up an email address there to make it happy.
Don't forget to run sudo postmap /etc/postfix/generic

i read this topic and installed it but not finish. i can send mail from this user to another user but i can't send mail to external? what do i do to install it?

can I use it with LAMPP php program under ubuntu 8.10?

what is the minimal setup and php-ing I must perform so it will
send me an email using php (on my Lampp server with local host )? (at the first stage doesn't matter if it will
be tagged as spam on my gmail)

Thanks
Israel

Your instructions are right on!

I want my machine to e-mail me if something goes wrong with my software RAID configuration. This post was very helpful.

Is there a way to skip postfix to send mail. I have to send mail to my cell phone when postfix is down!!!

I've been searching for this for a week now, followed your suggestions and everything worked fine!

Thanks again!

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. minneapolis airport car service

Hi,

Am new to Ubuntu.

Tried your settings as mentioned above, i get this error when try to send mails from outlook express. Without relay i have to set 'my server requires authentication'.

Do i need to confiure something on this server.

The server is Ubuntu Server v12.0

Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Account: 'mail.albateeltravel.com', Server: '192.168.1.5', Protocol: SMTP, Port: 25, Secure(SSL): No, Socket Error: 10053, Error Number: 0x800CCC0F

How can i resolve this so that the clients can send VIA this server and if possible change the port on the clients also so as to reduce spamming issues.

please help !

I think you're trying to do something that is beyond the scope of this article. This article was just about sending mail from Ubuntu/Linux. It seems like you want to use your Ubuntu box to send outgoing mail. That is a much more complicated problem.

Thanks for the writeup. I found the article by searching for "ubuntu testing mail" on google. I wanted to find a quick way to test mail sending from webapps on a host on a private network, without having to wade into docs for MTA's.

To confirm, I followed the outlined procedure on ubuntu 12.04. It worked without any problems. The setup just took a few minutes.

I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites blog site list and will be checking back soon. event producer

Hi experts,

I have a problem with email send back and forth. I can send email from my local domain at home using postfix, doveco in Ubuntu. When I receive my email from gmail and I tried to send back to see if I can receive from local email. gmail messaged that godaddy domain kicked back to gmail. I am currently purchased domain at godaddy but I didn't buy email from the domain yet. My friend said I can create it. Therefore, I got problem. For example, my domain name is abc.com where I bought at godaddy. My email at local at home is using info@abc.com. When I reply back to info@abc.com, the message deliver failure from godaddy sent back right away. How can I solve this method? Thank you very much for you help. Have a great day, experts.

Your article was great. I am now able to get the perl function working which I use to provide email notification of process progress on my system. This prevents me from having to login remotely to check progress. I was having issues getting past the reverse arp used by my ISP and configuring the smtp_generic_maps solved the issue for me. Thank you for a well written explanation.

Tested, Worked
Great! Thanks for your guides. I encountered this problem in 2 months ago and now got the problem solved.

Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share. INFILTRATION

Marvelous article! I need individuals to know exactly how great this data is in your article. It's fascinating, convincing substance. Your perspectives are much like my own particular concerning this subject.appvn download

Our services are available in all cities of Minneapolis and its surroundings. We are having years of experience which enabled our customers and clients to trust our services. itube app download

Idiotic and additionally trusting people at the same time can be an obstacle, on aged and also fully grown folk assembled also will follow a complication. Age and also embryonic concern together.

Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. Brawl Stars Hack

very couple of websites that occur to be in depth beneath, from our point of view are undoubtedly nicely really worth checking out..!chat online

I needed to thank you for this phenomenal read!! I unquestionably adored each and every piece of it. I have you bookmarked your site to look at the new stuff you post.!
voyance gratuite carte

Pages

Add new comment