User Tools

Site Tools


linux:applications:mailserver

Mailserver

Make sure your mailserver is properly set up and mails not considered as SPAM. Take a look at this checklist: http://www.linuxmail.info/mail-server-checklist/

host file

Mail servers usually depend on the local host file.

If you don't want to risk to find yourself on a spam list, make sure you specify your domain correctly.

Example

The format must be <IP Adress> <full qualified domain name> <host name> <alias 1> <alias 2> etc.

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
83.231.177.233  eul0001162-vmware2.eu.verio.net eul0001162-vmware2 eul0001162vmc
192.168.63.233  eul0001162-vmware2.eu.verio.net eul0001162-vmware2 eul0001162vmc
192.168.214.131 eul0001162-vmware2.eu.verio.net eul0001162-vmware2 eul0001162vmc

Following the setup above the mail server is going to use put a correct domain name in the header:

Received: from eul0001162-vmware2.eu.verio.net (eul0001162-vmware2.eu.verio.net [83.231.177.233])

You will still be able to send emails with another sender address domain. As example you could still send mails as fritzli@example.com just make sure the IP of the mailserver is allowed in DNS (as MX or over a SPF record).

Sendmail

Take a look at the online documentation.

Configuration

  • Edit /etc/mail/sendmail.mc
  • Run
    m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Postfix

Troubleshooting

Check the mailserver logs

tail /var/log/maillog

Search for messages in the maillog other than "stat=Sent"

egrep -i "(stat=[^Sent])+" /var/log/maillog | less 

Send mails from the console

  • use the “mail” command line utility and set a subject with the -s option
  • enter text to include within the mail (body) and tab Control D if your done
  • define a CC (optional) a tab Enter
$ mail -s "Testmail" nik@example.com
Hello, I'm just sending a testmail...
[Ctrl + D]
Cc:
[Enter]

Send mails with the php mail function

 php -r "mail('nik@example.com', 'The subject' , 'put your text here', '');"

Send mail over telnet

telnet mailserver 25
helo root
mail from:root
rcpt to:nik@example.com
data
Hello
.
QUIT

Receive status emails from the server

To receive status emails from the server, the easiest is to configure /etc/aliases in order to receive mails for root:

# Person who should get root's mail
root:           admin@example.com

To make the new alias effective type the following command:

newaliases
On older system (i.e. Red Hat EL 3) with postfix as mailserver, the aliases file can be found under /etc/postfix/aliases.
/srv/wiki.niwos.com/data/pages/linux/applications/mailserver.txt · Last modified: 2012/08/07 10:02 by niwo