msmtp+mutt 服务器批量发送邮件

作者:Chris

1.msmtp安装 #

wget http://downloads.sourceforge.net/msmtp/msmtp-1.4.32.tar.bz2?modtime=1217206451&big_mirror=0

tar jxvf msmtp-1.4.32.tar.bz2
cd msmtp-1.4.32
./configure --prefix=/usr/local/msmtp
make
make install
cd /usr/local/msmtp
mkdir etc log
cd etc
ln -s /usr/local/msmtp/bin/msmtp /usr/bin/msmtp
编辑配置文件
vi /usr/local/msmtp/etc/msmtprc

# Set default values for all following accounts.
defaults
logfile /usr/local/msmtp/log/msmtp.log
# The SMTP server of the provider.
account test
# SMTP邮件服务器地址
host smtp.xxx.com
# 发送的邮件e-mail
Email root@test.com
auth login
# 邮件服务器登录账号
user root@test.com
# 邮件服务器登陆密码
password
# Set a default account
account default : test

安装完成检测 

查看msmtp配置
msmtp -P

测试msmtp安装是否成功
msmtp -S
msmtp 邮箱地址
查看/usr/local/msmtp/log/msmtp.log

<div>
  <span style="font-family: Consolas"> </span>
</div>

<p>
  <span style="font-size: medium"><!--?xml version="1.0" encoding="UTF-8" standalone="no"?--></span>
</p>

<div style="color: #000000">
  <div>
    <div>
      <h2>
        <span style="font-family: Consolas">2.安装mutt</span><br />
      </h2>
      
      <div>
        <span style="font-family: Consolas">yum -y install mutt</span>
      </div></p>
    </div>
    
    <div>
    </div>
    
    <div>
      <div>
      </div>
      
      <div>
        <span style="font-family: Consolas">可以使用which mutt查看mutt安装的路径。 </span>
      </div>
      
      <div>
        <span style="font-family: Consolas">编辑mutt配置文件:vi /etc/Muttrc,</span>
      </div>
      
      <div>
        <span style="font-family: Consolas">在最后添加以下几行:</span>
      </div>
      
      <p>
         
      </p>
      
      <pre>set from="发送邮件地址"

set sendmail="/usr/local/msmtp/bin/msmtp"
set use_from=yes
set realname="发送邮件地址"
set editor="vi"

      <p>
         
      </p>
      
      <div>
        <span style="font-family: Consolas">保存退出,测试一下mutt是否有效:</span>
      </div>
      
      <p>
        <span style="font-family: Consolas">echo &#8220;测试&#8221; | mutt -s &#8220;测试&#8221; 测试邮件地址 -a 附件</span>   <!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->
      </p>
      
      <h2>
        <span style="font-family: Consolas">3,shell配置</span><br />
      </h2>
      
      <div>
        <span style="font-family: Consolas"> </span>
      </div>
      
      <div>
        #/bin/sh <div>
          #调用mutt发送邮件
        </div>
        
        <div>
        </div>
        
        <div>
          echo &#8220;Sending mail&#8230;&#8221;$(date  +&#8217;%Y-%m-%d_%H-%M-%S&#8217;)
        </div>
        
        <div>
        </div>
        
        <div>
          filename=“xxxxx&#8221;
        </div>
        
        <div>
          subject=“xxxxx”
        </div>
        
        <div>
          filename=“xxxxx”
        </div>
        
        <div>
        </div>
        
        <div>
          echo “$content&#8221; | mutt -s “$subject&#8221; 邮件地址 -a $filename
        </div>
        
        <div>
          echo &#8220;Sent OK&#8221;
        </div></p>
      </div>
      
      <p>
        <span style="font-family: Consolas"> </span> </div>
      </p>
    </div>
  </div>
  
  <div style="color: #000000">
  </div>
  
  <p>
    <span style="font-size: medium"> </span>
  </p>

您的评论

Build by Loppo 0.6.14