17

I run a simple server that I administrate remotely, and I need it to be able to send an email to my personal email address every time an error occurs. With the default setup on Ubuntu, sendmail just accumulates emails in /var/spool/mail that are to be sent locally, but I need it to go to an external email.

The tutorials I've found all talk about setting up postfix/sendmail as a full-fledged email server, but I just need outgoing only, no external logins. Is there an easy way to do this?

Michael
  • 291
  • 1
  • 2
  • 8

6 Answers6

2

Check that your server is open to the world in port 25 ( outgoing only). And the dns is configured correctly. You are not suppose to do anything to sendmail for sending outgoing mails.

Igal Serban
  • 1,575
  • 10
  • 6
2

You should also pay attention if you need a relay host and define it (DSmy.relay.host)

Xavier Maillard
  • 201
  • 2
  • 4
2

Maybe nullmailer is for you.

Marian
  • 278
  • 1
  • 4
  • 1
    I used to use nullmailer, but moved away from it due to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=329192 it was partially but not completely fixed. – Peter Green Nov 21 '15 at 02:43
2

Assuming you are actually using postfix.

I would run dpkg-reconfigure postfix and select the "internet site" or "internet site with smarthost" (if you want to send the mail through a smarthost) option as a starting point. This will enable you to send mail to and receive mail from the internet.

If you don't want the box to be able to receive mail then I would suggest configuring the SMTP server to listen on localhost only. See https://superuser.com/a/430329/506601

Peter Green
  • 4,056
  • 10
  • 29
1

Open /etc/aliases with a text editor (using sudo) and change the root line to be your email address, or add another line with your local user in it on the left hand side, and on the right hand side enter your email address:

root:        my@email.com

then after saving the aliases file, run newaliases command:

$ /usr/bin/newaliases

Both sendmail and postfix are configured by default to send outbound mail on most systems.

EEAA
  • 108,414
  • 18
  • 172
  • 242
1

Here are some details on how to setup sendmail for Outgoing Only

Also on this page

I modified these steps from what is listed on the website for centos/Amazon Linux.

Here are the steps:

you may also need to install sendmail-cf
# yum install sendmail-cf

# cd /etc/mail
# nano local-host-names
add new line: localhost
save the file and quit the editor

# make
# nano sendmail.mc
add these lines above the other FEATURE lines near the top of the file:
MASQUERADE_AS(`yourdomain.com')dnl
FEATURE(masquerade_envelope)
save the file and quit the editor

# m4 sendmail.mc > temp.cf
# mv temp.cf sendmail.cf
# make
# /etc/rc.d/init.d/sendmail restart
Beachhouse
  • 208
  • 1
  • 5