close

Send Email using Mutt Program In Linux

Step 1. Install ssmtp program to deliver an email from a server to a configured mailhub.

# rpm -Uvh ssmtp-2.61-21.el5.x86_64.rpm
# rpm -qa |grep ssmtp
ssmtp-2.61-21.el5

Step 2. Modify /etc/ssmtp/ssmtp.conf configuration file and specify mailhub domain and port number as follows:
mailhub=mail.danbrother.com:25

Step 3. Change the Mail Transfer Agent(MTA) to ssmtp:

# alternatives --config mta

There are 2 programs which provide 'mta'.

Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.ssmtp

Enter to keep the current selection[+], or type selection number: 2


# alternatives --display mta | grep "link currently points to"
>>
link currently points to /usr/sbin/sendmail.ssmtp

 

Step 4: Install mutt program (if not being installed) to send email

# rpm -Uvh mutt-1.4.2.2-3.0.2.el5.x86_64.rpm
# rpm -qa |grep mutt
mutt-1.4.2.2-3.0.2.el5

 

# mutt -help

Mutt 1.4.2.2i (2006-07-14)
usage: mutt [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> ]
mutt [ -nx ] [ -e <cmd> ] [ -a <file> ] [ -F <file> ] [ -H <file> ] [ -i <file> ] [ -s <subj> ] [ -b <addr> ] [ -c <addr> ] <addr> [ ... ]
mutt [ -n ] [ -e <cmd> ] [ -F <file> ] -p
mutt -v[v]

options:
-a <file> attach a file to the message
-b <address> specify a blind carbon-copy (BCC) address
-c <address> specify a carbon-copy (CC) address
-e <command> specify a command to be executed after initialization
-f <file> specify which mailbox to read
-F <file> specify an alternate muttrc file
-H <file> specify a draft file to read header from
-i <file> specify a file which Mutt should include in the reply
-m <type> specify a default mailbox type
-n causes Mutt not to read the system Muttrc
-p recall a postponed message
-R open mailbox in read-only mode
-s <subj> specify a subject (must be in quotes if it has spaces)
-v show version and compile-time definitions
-x simulate the mailx send mode
-y select a mailbox specified in your `mailboxes' list
-z exit immediately if there are no messages in the mailbox
-Z open the first folder with new message, exit immediately if none
-h this help message

 

 Step 5: use mutt command to send an email

# mutt -s "Email Test using Mutt Program" -a /message/memo.txt -- danbrother@pixnet.net < message_body.txt

If you need to specify the "From Address" , use the following command instead:
# mutt -e 'set from=system@myserv.com-s "Email Test using Mutt Program" -a /message/memo.txt -- danbrother@pixnet.net < message_body.txt

 

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 DanBrother 的頭像
    DanBrother

    DanBrother的部落格

    DanBrother 發表在 痞客邦 留言(0) 人氣()