Thursday, October 4, 2012

Linux Sendmail Configuration

Configuring Sendmail to send mail from command line

Sendmail is defualt MTA for most of the Linux distro  and very useful for system administration like if you want to cron alert you should have sendmail configured or want to server alert you should have sendmail or any other MTA but i recommend sendmail is best choice easy to use and setup.

So lets  get start  ed :)

Configuring it is very simple. First you'll need the sendmail-cf package. Install it using yum:
[root@server ~]# yum install sendmail-cf
Edit the file /etc/mail/sendmail.mc and add the following lines. Make sure you set your mail server domain name where it's bolded:
MASQUERADE_AS(yourdomain.com)dnl
MASQUERADE_DOMAIN(yourdomain.com)dnl
In the same file /etc/mail/sendmail.mc remove the "dnl" from the beginning of the lines so it will look like this:
LOCAL_DOMAIN(`localhost.localdomain')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
Save the file and compile it using m4:
[root@server ~]# m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
Send Sendmail a -HUP signal using kill or simply restart the daemon for the configuration changes to take effect:
[root@server ~]# service sendmail restart

Testing your configuration using sendmail

And that's it! you're done. Just send yourself a test email to make sure it is really working:
[root@server ~]# /usr/sbin/sendmail -t < mail.txt
Where the contents of the mail.txt file are:
Date: Thu Nov 11 08:41:54 2007
To: you@somewhere.com
Subject: The subject of the message
From: whatever@somewhere.com
Body of message goes here

Testing your configuration using mutt

You can also use mutt/mail to test, which is a bit simpler (and you can also add the -a parameter for file attachment):
[root@server ~]# mutt -s "Test Email" you@somewhere.com < /dev/null
[root@server ~]# mail -s "Test Email" you@somewhere.com < /dev/null

Troubleshooting mail server using telnet .

http://linuxtroops.blogspot.in/search?q=telnet+25

No comments:

Post a Comment