Monday, 3 June 2013



unix mail utilities mail or mailx can be used to send mails to  users within a machine, a remote machine or web users using a relay server.

To end mail to user hradmin on the machine v_serv1
/home/gadm$ mail x –v  -s “intimation”  hradmin@vserv_1  <mail_content_file
Here  the text “intimation”after –s  is the subject and mail_content_file contains mail body.

Configurations for sending external mails through a relay server(eg IBM LOTUS) .
1)make an entry of mail relay server in /etc/mail/ file(can be done from root login)
vi /etc/mail/
DS<mail relay server name>  ->add your mail server hostname in domain form(eg:

2)  edit /etc/hosts file and make an entry  of mail relay server.     <mail_svr_hostname>    <domain_name>
Also If your hostname contains only IP and plain hostname like  <my_hostname>,
Add another column  to make your hostname have a valid domain name(eg .com) otherwise you will get “hostname not qualified” error.  <my_hostname>   <my_hostname@<my_domain>

Ask your mail admin to add this hostname as a qualified  hostname  for receiving mails from.

3) stop and start the sendmail daemon.
stopsrc -s sendmail
startsrc -s sendmail -a “-bd -q30m”

Now you can send external mails using mailx command as follows.(AIX)
mailx  -v -s “<subject>” -r “< sender_name>”  -c  ”<cc_address(es)>”  <to_address>  < content_attach
“<subject> “         Is a quoted text   received  under subject(quoting is must when there is space in the text.
<sender_name>     Is the  name of the sender as seen by the recipient. If it is not used the recipient will see the sender as your <default>.
”<cc_address(es)>  Refer to those addresses to whom you need to send the copies of this mail to.
“<to_address>     Actual recipient address.
content_attach    A file containing body of the mail and encoded attachments.

A file like conetent_attach can be formed by using the uuencode command. For example if you hava a content file named  c_mail_body.txt  and an attachment  /home/v_admin/pdf_archive/trans_list.pdf  file   to send .
Uuencode  /home/v_admin/pdf_archive/trans_list.pdf   trans_list.pdf    >> c_mail_body.txt 
Now the file c_mail_body.txt   will contain both mail contents and attachment. You can use this file  to input  as content_attach  file  in the mailx  syntax.
mailx  -v -s “<subject>” -r “< sender_name>”  -c  ”<cc_address(es)>”  <to_address>  < c_mail_body.txt 

No comments:

Post a Comment