- Turn your computer on.
- Press ESC at the grub prompt.
- Press e for edit.
- Highlight the line that begins kernel ………, press e
- Go to the very end of the line, add rw init=/bin/bash
- press enter, then press b to boot your system.
- Your system will boot up to a passwordless root shell.
- Type in passwd username
Friday, September 18, 2009
Wednesday, September 16, 2009
Aliases is used to handle mails to a non existing address. This will allow to redirect the msgs destined to a given name to a real user.
The Aliases File:
Default Aliases in system:
When a msg is bounced or problem delivering a msg the destination of the msg will be MAILER-DAEMON.
i.e, if a mail is send to a non existing user then the mail header is modified to MAILER-DAEMON as user.
This means the problem msg or bounced msg has to go some where, and sendmail delivers it to MAILER-DAEMON.
MAILER-DAEMON is aliased to postmaster, and postmaster aliased to root - hence the mail is delivered to root.
Aliases File is case insensitive:
The aliases defined in sendmail is case insensitive.
After changing the aliases no need to restart or reload the sendmail service because in each and every request sendmail consults the db of aliases.
Types of aliases defined
There are 5 types of aliases:
1. 1-to-1 Aliases.(1 alias map to one local username)
This will allow aliases to include the list from separate file
4. File Redirection Aliases - Re-route the message to file
5.Redirecting the E-mail to PIPE (redirecting the output to an application)
when a mail comes we can send the output to certain commands. for example if mail comes for the user john and the is in vacation then we can redirect the mail to the program "vacation" to send the automated reply.
kiran: "|/usr/bin/vacation kiran"
# sendmail -bv support
kiran... deliverable: mailer local, user kiran
To enable the vacation program for an user called fazi install the vacation program that comes along with the sendmail binary.
Create a forward file
# vim ~/.forward
\fazi, "|/usr/bin/vacation -t0 fazi"
# vim ~/.vacation.msg
Hi Thanks for you mail !
hai i am on vacation
will ping you once i'm back
#grep -i mail /etc/syslog.conf
# Log anything (except mail) of level info or higher.
# Log all the mail messages in one place.
mail.* ; -/var/log/maillog
severity = info,err,warn,debug
destination = /var/log/messages, /var/log/maillog
/var/log/messages will be logged other than all mail logs, i.e no maillogs will be logged to /var/log/messages and /var/log/maillog will be logged with all the mail activities.
To log the mail activities separately use the following option in /etc/syslog.conf
Ack Log for msg received in MTA:
Sep 13 09:08:36 centos sendmail: n8D58YWM006265: from=
Daily Time stamp: message came from server: Daemon: Process ID: queue ID: From Server: size of message: class: number of recipient: msg id: relay=root@localhost (who has send the message from which host)
MSG Delivery Log:
Sep 13 09:08:36 centos sendmail: n8D58YWM006265: to=
Time stamp:hostname:daemon:PID:queue ID: to=recipient:ctladdr=is the local user who sends the msg (ctladdr user ID /& Group ID):delay=is expressed the amount of time between the msg recieved and delivered:xdelay=amount of time taken to transfer the msg (from user to user or host to host):mailer=the type of the mailer used in sendmail:pri=priority:dsn= Delivery Status Notification(Email Delivery Error Codes ):status=status of msg delivery
How many times you got your outgoing emails back and wondered what is wrong with it? Every time when your email can not be delivered, the SMTP server sends you a notification, which includes a standard error message, associated with the real problem.
Each code is composed of three digits (X.X.X). The first digit gives the status of the email message:
Here is a complete list of email delivery error codes, based on the Extended SMTP (ESMTP) standards, where X can be 4 or 5, depending on the error type (Persistent Transient or Permanent):
For checking the mail log - Better to grep the queue id from maillog to check the msg status:
# grep queueid /var/log/maillog
# grep "Aug 15" /var/log/maillog
Tuesday, September 15, 2009
Local Mail Delivery:
Locally sendmail MTA places mails to /var/spool/mail/$USER
now the MUA (mutt/mail) (mail clients) will spool the mail from the /var/spool/mail/$USER and will place in the users home directory, either mbox or Maildir/
Route of Local mail delivery:
sendmail -> MSP (MSP sends to Clientmqueue directory) -> MTA -> sends the message described as in local mailer sends to procmail -> /var/spool/mail -> MailClient -> $user home
Sendmail injects msgs to MSP which moniters the clientmqueue then msgs is taken by MTA which checks whether the mail is for local delivery or not. if so the MTA will invoke procmail which puts the msgs in the users mail box /var/spool/mail/$user according to procmail filter rules. Then the mail client copies the mail to users home directory. Usually the msg client reads the mail from /var/spool/mail/$user.
mbox is the traditional way of saving messages in users home directory,Nearly all MTA's and POP/IMAP daemons know how to deliver to mbox. This format simply appends each received message into a file called "inbox". Out of the box, nearly all MTA's will come configured this way, and it does have decent performance for a lightly loaded mailserver.
This sets up a directory structure whereby each message that is received is it's own file. This is how most major mail hosting providers run their infrastructure. The reason being is that when a user checks their email, or the MTA has to deliver a newly received message, it does not have to open up a single file and append/read to/from it. This comes into play when a user has a lot of stored mail on the server.
Sending mail from shell
#sendmail -v kiran
will send the mail to user kiran.this will show the details in verbros.
Analyze the verbose output.
the out put which starts with ">>>" indicates that the command is issued by local sendmail command
"250" "any 3 digit number" indicates that the command is done by MTA.
if the 3 digit is ending without "-", this is the indication to the local mail client saying that the MTA server has finished its output.
In MSP mode sendmail will accept messages injected in to the queue from local users, scripts or program locally and delivers the msg when the msg deliver agent MTA is available.
Starting sendmail as MSP:
#/usr/sbin/sendmail -L sm-msp-queue -Ac -q30m
-L = Set the identifier used in syslog messages to the supplied tag
sm-msp-queue = Tag that denotes sendmail as running in msp queue mode, which accepts local msgs injected in to queue.
-Ac = instructs sendmail to use the alternate config file instead of sendmail.cf file, i.e the submit.cf file
-q30m = this is the queue runner, which will re run the queue after given time if the mail is delivered.
Now check the process is running successfully by
#ps -ef |grep sendmail
smmsp 3023 1 0 17:22 ? 00:00:00 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue
sm-client.pid is the file inside /var/spool/clientmqueue with the process id .
Killing /stoping the sendmail
#kill `cat sm-client.pid`
so the sendmail msp will be killed
Testing the sendmail as MSP
Now the mail will be accepted by MSP in the queue.
this wont be delivered to destination because now the MTA is not running in the machine. So it is queued under /var/spool/clientmqueue
there are 2 types of files created in the clientmqueue director
df* = file contains the message body
qf* = file contains the message headers
So while running the sendmail in MSP mode it will accepts the messages from programs/users and for delivery/relay of the mail we need MTA.
To show the details of Logging Process of the mail program
#grep -i mail /etc/syslogd.conf
Sendmail As Mail Transfer Agent - MTA
# sendmail -L sm-mta -bd -q1h
-L sm-mta = Set the identifier used in syslog messages to the supplied tag and name the tag as sm-mta
-bd = Running sendmail daemon in background
-q1hr = queue refresh happens in every 1 hr
This will invoke sendmail as daemon and will bind to the port 25.
Now check the sendmail process in the system -
# ps -ef |grep sendmail
smmsp 4725 1 0 18:46 ? 00:00:00 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue
root 5238 1 0 19:27 ? 00:00:00 sendmail: accepting connections
The first process concern with MSP which will accepts the messages from programs/users
The second Process runs as MTA which will run as Mail Transfer Agent
Now create the sendmail start up script to run the sendmail on boot. Refer the online sendmail startup scripts
To Clear the queue created by MSP while MTA was down kill the sendmail with MSP and re-run the sendmail as MSP this will force sendmail MSP to submit the mails in the clientmqueue to MTA.
#kill `cat sm-client.pid`
#sendmail -L sm-msp-queue -Ac -q30m
Sunday, September 13, 2009
Compiling Installing and Testing Sendmail
1. Download sendmail & GPG Key
2. Download the GPG key and check the integrity of the file
compare with md5sum in the website for both packages
GPG Key Check
#gpg --import sendmail_gpgkeys
#gpg --verify sendmail.8.14.2.tar.gz.sig sendmail.8.14.2.tar.gz
3. Install sendmail
Extract the downloaded archieve
# tar -zxvf sendmail.8.14.2.tar.gz
# cd sendmail-8.14.2
Lists the folders inside the source code below are some important Folders inside the source code:
contains sample config files ideal for enviornment
contains the source code provided by third party
plugins for clamav, spamassassin etc
makemap utility for the configurations
contains the sourcefiles with the Bulid exicutable which uses for installation
Bulding the source code
This directory contains all the binaries & object files
Now go to other directories Build & install the binaries & configurations
# cd ../cf/cf
Here we can find the platform specific configuration files of sendmail, each *.mc file contains corresponding *.cf file
so check for generic-linux.mc and copy to sendmail.mc file to create the configuration file. sendmail.cf file is used by sendmail while running as a MTA (mail Transmission Agent)
We need the submit.mc file as well. this file is used by sendmail while running as Mail Submission Program (MSP)
submit.mc is used while local mail submition to sendmail queue
# cp generic-linux.mc sendmail.mc
now we have both mc files submit.mc & sendmail.mc file in place
# ./Build install-cf
(install-cf Installs the configuration files) This will run the m4 process which will export the submit.mc & sendmial.mc to /etc/mail by creating the *.cf file
# ls /etc/mail
check the /etc/mail directory folders for the sendmail.cf and submit.cf file
Now add the user&group so that a portion of sendmail can be run without the root privilage,the sendmail daemon runs with root privilages so this step is needed to avoid the security issue
Now install the main binary files
#ls -al /usr/sbin/sendmail
Now go to directory makemap and build and install the makemap utility
Now go to mailstats directory - Build & install mailstats
# cd ../mailstats/
# ./Build && ./Build install
Post Installation Chores:
Check the sendmail configurations and files are correct
# sendmail -v -bi
this will show the errors in configurations, permission problems, alias problems etc.
In my case it given error for /etc/mail/local-host-names & /var/spool/mqueue/
so we need to define the file /etc/mail/local-host-names
When sendmail receives mail, it needs a way of determining whether it is responsible for the mail it receives. It uses the /etc/mail/local-host-names file to do this. This file has a list of hostnames and domains for which sendmail accepts responsibility. For example, if this mail server was to accept mail for the domains my-site.com and another-site then the file would look like this:
Create the local-host-name file
#echo "localhost" > /etc/mail/local-host-names
When Sendmail functions as MTA it stores file in /var/spool/mqueue/ directory.So this directory is very much in need.
in MTA: If the mail delivery is not happening with respect to any config issues or unavailability of the mail destination the mails are stored in /var/spool/mqueue/ directory
in MSP: if mail delivery is not happening it stores mail in clientmqueue directory
#chmod 700 /var/spool/mqueue/
#chown smmsp:smmsp /var/spool/clientmqueue
#chmod 770 /var/spool/clientmqueue
Now again run the sendmail checking utility
#sendmail -v -bi
If can see the /etc/mail/aliases file is missing, go to sendmail source code directory and copy the aliases file to /etc/mail and generate the db file of aliases
# cp aliases /etc/mail/
if the db converting tools (db4 & db4-devel) are not installed before the sendmail compilation we have to install the db tools which is required for aliases databases creation, then recompile the sendmail source code to include the utility.
Now again run the sendmail checking utility
#sendmail -v -bi
Now this gives the tottal number of aliases in the aliases file. This means that we have installed the sendmail packages correctly.
Man page error while compiling
Because the sendmail assumes that the man page directory as /usr/man and normal linux systems uses /usr/share/man
so creating a soft link of /usr/share/man to /usr will solve this issue
#ln -s /usr/share/man /usr
So using the same method we can install all the binaries available with in the sendmail sorce-code to get a full fledged sendmail server.
The /etc/hosts file should be updated properly to work sendmail smoothly.