Page 1 of 1

Ubuntu Server Mail Help Requested

Posted: Tue May 21, 2013 4:48 pm
by Tony
I've got an Ubuntu server installation and I'd like to receive e-mail based alerts when security related incidents happen such as repetitive failed SSH login attempts. I've been working all day with no luck on getting postfix to send the messages but so far when I runn the command...
echo "This is Content" | mail -s "This is Subject" [email protected]
what I get in the /var/log/mail.log is
May 21 16:36:22 64-142-41-249 postfix/smtp[17093]: 5521E80258: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:11125, delay=0.52, delays=0.17/0.01/0.31/0.03, dsn=5.1.8, status=bounced (host 127.0.0.1[127.0.0.1] said: 553 5.1.8 <[email protected]>... Domain of sender address [email protected] does not exist (in reply to MAIL FROM command))
This is after installing and configuring stunnel to handle the secure communication, which is also after attempting to just use straight postfix. Am I headed down a giant rabbit hole here or just missing something silly?
I have a static DSL connection provided by Sonic.net As I understand it, I cannot send mail from my house using TCP port 25. So I've tried various combinations of TCP ports 465 and 587 with authentication.
Any help to point a semi-compitent linux user in the right direction would be greatly appreciated. I can provide whatever further details are needed.

Re: Ubuntu Server Mail Help Requested

Posted: Tue May 21, 2013 9:49 pm
by toast0
I think I can help; but let me confirm I understand the question:

You're running Ubuntu server on your Sonic DSL line with static IP, and you want it to send mail to your regular sonic mailbox when something exciting happens?

Option 1, there is a knob in member tools to allow port 25 (incoming and outgoing) for users with a static connection. The direct link is https://members.sonic.net/connections/dsl/firewall/

Option 2, (which is what I'm using), is to relay your mail through sonic's outgoing mail server, in /etc/postfix/main.cf I have

Code: Select all

relayhost = [mail.sonic.net]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
and /etc/postfix/sasl_password is a text file that looks like

Code: Select all

mail.sonic.net  toast0:mypassword
and you run sudo postmap /etc/postfix/sasl_password so postfix can read that (maybe this could be made easier, i set it up in 2009, and haven't touched this part since)

Re: Ubuntu Server Mail Help Requested

Posted: Tue May 21, 2013 9:55 pm
by toast0
Actually looking at the FAQ on the firewall setup page; port 25 to mail.sonic.net should be open from any Sonic connection anyway; I think I set up the relay and auth settings while I was temporarily on another provider (but wanted to keep my mail flows the same), and I just never changed things back. You can probably just put relayhost = [mail.sonic.net] and have everything work fine.

Re: Ubuntu Server Mail Help Requested

Posted: Tue May 21, 2013 10:36 pm
by fmc
Consider installing and using sshguard. I like to run it with "-p 75", which blackholes the probing address for 75 seconds give or take, which is kind of like dropping carrier and making them redial, just like in the old days when you flubbed your password too many times when timesharing. This seems to suffice for making most of the probers go away.

Also consider requiring public key authentication, if you and your ssh users can handle that.

Between these, you may not need to get that e-mail after all.

Re: Ubuntu Server Mail Help Requested

Posted: Tue May 28, 2013 2:12 pm
by kavan
I may be a bit late to the party but it appears the answer lies in the error.

Domain of sender address [email protected] does not exist (in reply to MAIL FROM command))

You need to set a valid domain on the "From" email address. It is a bit odd to me that it is pulling that particular zone/name. x-x-x-x.static.sonic.net and x.x.x.x.dsl.static.sonic.net should both resolve and be the actual rDNS setting unless your specific zone got messed up some how.

Re: Ubuntu Server Mail Help Requested

Posted: Sun Oct 05, 2014 2:12 pm
by Brooks Moses
For the record, I also had to add the following to my main.cf file to get this to work:
smtp_sasl_security_options = noanonymous

(The default is noplaintext, noanonymous, and so this removes the noplaintext to allow plaintext logins.)

Re: Ubuntu Server Mail Help Requested

Posted: Fri Jan 09, 2015 1:20 am
by forest
It's worth mentioning that Dragonfly Mail Agent is available in the Ubuntu repositories. It works nicely for outgoing-only purposes like the one described here, with much simpler configuration than postfix.

https://github.com/corecode/dma

http://packages.ubuntu.com/search?keywords=dma