ubuntu下msmtp+mutt的安装和配置
1.mutt+msmtp的安装
sudo dpkg -i package.deb
以下是在线安装方式,我们可以在安装信息中看到有哪些依赖包,我们记住这些依赖包的名称,到时候拷贝出来就好了。
bitnami@linux:/var/cache/apt/archives$ sudo apt-get install mutt
[sudo] password for bitnami:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgpgme11 libpth20 libtokyocabinet8
Suggested packages:
gpgsm urlview aspell ispell mixmaster
The following NEW packages will be installed:
libgpgme11 libpth20 libtokyocabinet8 mutt
upgraded, newly installed, to remove and not upgraded.
Need to get , kB of archives.
After this operation, , kB of additional disk space will be used. bitnami@linux:~$ sudo apt-get install msmtp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgsasl7 libntlm0
Suggested packages:
msmtp-mta
The following NEW packages will be installed:
libgsasl7 libntlm0 msmtp
upgraded, newly installed, to remove and not upgraded.
Need to get kB of archives.
After this operation, , kB of additional disk space will be used.
Do you want to continue [Y/n]?
2.配置msmtp和mutt
2.1配置msmtp
$ sudo vim ~/.msmtp.log
配置msmtp配置文件“.msmtprc”
#Accounts will inherit settings from this section
defaults
# A first gmail address
account gmail
host smtp.gmail.com
port
from username@gmail.com
user username@gmail.com
password password
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# A second gmail address
account gmail2 : gmail
from username2@gmail.com
user username2@gmail.com
password password2
# A freemail service
account freemail
host smtp.freemail.example
from joe_smith@freemail.example
user joe.smith
password secret
# A provider's service
account provider
host smtp.provider.example
# A emali
account
host smtp..com
port
from aaa@.com
auth login
tls off
user aaa@.com
password password
logfile ~/.msmtp.log
# Set a default account
account default :
配置.msmtprc权限,以下设置是只给.msmtprc的所属用户读和写的权限,其他人没有任何权限
$ sudo chmod .msmtprc --设置配置文件权限
如果要查看.msmtprc的所属用户,可以通过以下命令查看,我们可以看到,.msmtprc这个文件所属用户是root用户,组是root组。
root@BJCGNMON01:~# ls -l .msmtprc
-rw------- root root Feb : .msmtprc
以上设定很重要,使用什么账户去调用msmtp,那么该账户就要有对 .msmtprc文件的读写权限。
2.2配置mutt
#sudo vim ~/.muttrc
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="name"
set from=aaa@.com
set envelope_from=yes
我只想给我当前root用户配置mutt功能,所以使用后者。修改完毕以后也需要查看这个文件的读写权限,当前是root账号要使用mutt功能,那么这个.muttrc就必须对于root账户有读写权限。查看权限的方法如下:
root@BJCGNMON01:~# ls -l .muttrc
-rw-r--r-- root root Feb : .muttrc
3.测试smtp的信息
3.1msmtp测试
测试命令:
测试配置文件:msmtp -P
测试smtp服务器:msmtp -S
还有一种方法是在配置msmtp之前就可以进行测试,比如测试163的smtp的命令如下:
bitnami@linux:~$ msmtp --host=smtp..com --serverinfo
SMTP server at smtp..com (smtp..gslb.netease.com [220.181.12.18]), port :
.com Anti-spam GT for Coremail System (163com[])
Capabilities:
PIPELINING:
Support for command grouping for faster transmission
STARTTLS:
Support for TLS encryption via the STARTTLS command
AUTH:
Supported authentication methods:
PLAIN LOGIN
This server might advertise more or other capabilities when TLS is active.
从返回信息中我们可以看到,这个smtp是支持TLS的,验证方式支持 PLAIN 和 LOGIN
3.2测试邮件
echo "test" |mutt -s "my_first_test" aaa@.com
如果是多个收件人,那么使用空格或者逗号分开即可,测试命令:
echo "test" |mutt -s "my_first_test" aaa@.com bbb@.com
echo "test" |mutt -s "my_first_test" aaa@.com,bbb@.com
(PS:windows邮件客户端blat,2014-6-23)
而对于windows下的邮件发送客户端blat来说,只能使用逗号分隔多个邮件列表,测试命令如下:
blat -install .smpt.com aaa@.com --注册
blat %varlogfile% -to aaa@.com,aaa@.com" -u "aaa" -pw "aaa" -subject "content" -attach %varlogfile% --发送
我们上面都是将echo后面的内容作为邮件正文,也可以将邮件的内容写在一个文件里面,然后将这个文件的内容发送出去。
touch mail.txt --创建邮件文本
vim mail.txt --编辑文本内容
this is is my first test email --文本内容
发送邮件,下面的示例是发送一个标题为linkmail,收件人是aaa@126.com bbb@163.com,附件是 /root/sent ,邮件内容是的mail.txt中的内容。发送脚本如下
mutt -s "linkmail" aaa@.com bbb@.com -a /root/sent </root/mail.txt
4.配置全局的msmtp和mutt
touch /var/log/msmtp.log
为了让所有用户都能读写这个日志文件,我们将其权限设置为777
chmod /var/log/msmtp.log
如果要修改用户、组、其他的单独权限,可以使用以下命令。u:user, g:group, o:other。
chmod u+rwx
chmod g+rwx
chmod o+rwx
2.创建msmtp的配置文件/etc/msmtprc
touch /etc/msmtprc
3.配置msmtprc
#Accounts will inherit settings from this section
defaults # A emali
account
host smtp..com
port
from aaa@.com
auth login
tls off
user aaa@.com
password password
logfile /var/log/msmtp.log
# Set a default account
account default :
4.配置mutt的全局配置文件/etc/Muttrc,在其最后加入以下信息:
set sendmail="/usr/bin/msmtp" #根据实际情况配置,默认安装的就是这个地址。
set use_from=yes
set realname="name"
set from=aaa@.com
set envelope_from=yes
5.测试
在执行测试命令的时候,会自动将邮件副本写入到“~/sent”当中。
echo "test" |mutt -s "my_first_test" aaa@.com
root用户发送邮件,邮件被保存在/root/sent当中,enadmin账户发送邮件,邮件被保存在/home/enadmin/sent。如果是其他类似于enadmin的用户,需要首先创建/home/username这个目录,然后修改这个目录的权限。
mkdir /home/nagios
chown -R nagios.nagios /home/nagios
6.常见问题:
错误1:msmtp: account default not found: no configuration file available
msmtp有bug,必须手动指定对应的配置文件
更改/etc/Muttrc中set sendmail="/usr/bin/msmtp"为set sendmail="/usr/bin/msmtp -C .msmtprc"
错误2:msmtp: GNU SASL: Base 64 coding error in SASL library
遇到Base64 编码错误
更改~/.msmtprc中auth login
为 auth plain
ubuntu下msmtp+mutt的安装和配置的更多相关文章
- Ubuntu 下 firebird 数据库的安装和配置
Ubuntu 下 firebird 数据库的安装和配置 1.简介 本文主要是 Ubuntu 下 firebird 数据库的安装和目录迁移,同样适用于 Debian 系统:Ubuntu 20.0.4 f ...
- Ubuntu下LaTex中文环境安装与配置
转载自:http://www.linuxidc.com/Linux/2012-06/62456.htm LaTeX是一个强大的排版软件,但是其最初只是为英文排版而设计的.为了使其能够胜任中文排版的重任 ...
- ubuntu下nfs服务器的安装与配置
nfs服务器的安装和配置 1.安装nfs 服务器,前提是你的系统能连上网. 2.设置/etc/exports配置文件 (1) 进入/etc/exports配置文件 (2) 在最后一行加入红色那行,/h ...
- ubuntu 下串口调试工具 minicom安装与配置cutecom安装
安装minicom: $sudo apt-get install minicom 配置minicom: 如果您的系统的默认语言不是英文,请执行下面的命令: $LANG=EN ...
- Ubuntu下redis数据库的安装和配置详细过程
Redis 安装 当前redis最新稳定版本是4.0.9 当前ubuntu虚拟机中已经安装好了redis,以下步骤可以跳过 最新稳定版本下载链接:http://download.redis.io/re ...
- ubuntu 下串口调试工具 minicom安装与配置
检查系统是否支持USB转串口: lsmod | grep usbserial 如果有usbserial,说明系统支持USB转串口. 识别串口设备: 插上USB转串口,在终端输入命令: #dmesg | ...
- ubuntu下samba服务器的安装与配置
参考网址:http://jingyan.baidu.com/album/00a07f38b9194082d028dc08.html?picindex=9 sudo service smbd resta ...
- ubuntu下opencv2.4.9安装测试
ubuntu下opencv2.4.9安装测试 whowhoha@outlook.com 一.依赖包安装 1. build-essential 软件包 sudo apt-get install bui ...
- Ubuntu16.04下LAMP环境的安装与配置
Ubuntu16.04下LAMP环境的安装与配置 最近做个实验需要用到Ubuntu环境的靶场,所以这里介绍下Ubuntu环境下LAMP的安装与配置,话不多说,我们gkd! 1.Apache2的安装 首 ...
随机推荐
- 月薪20K软件测试自动化岗必问面试题:验证码识别与处理
本文乃Happy老师的得意门生来自java全栈自动化测试4期的小核桃所作.正所谓严师出高徒,笔下有黄金~~让我们一起来征服面试官吧~~ 在做自动化测试的时候,经常会遇到需要输入验证码的地方,有些可以让 ...
- 字符串对象的charAt函数存在的意义
var style = ""; style[0] //undefined var style = ""; style.charAt(0); //"&q ...
- golang container heap&sort
go语言也自己的容器数据结构.主要有list.heap和ring package main import ( "container/heap" "fmt" &q ...
- RESTful 个人理解总结【转】
转自:http://www.cnblogs.com/wang-yaz/p/9237981.html 一.什么是RESTful 面向资源 简单的说:RESTful是一种架构的规范与约束.原则,符合这种规 ...
- C#排队处理DEMO
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 001_软件waf
一.优秀的软件waf开源软件 <1>openwaf介绍 http://www.oschina.net/p/openwaf http://git.oschina.net/miracleqi ...
- 七、vue语法补充二(动态组件 & 异步组件、访问元素 & 组件、混入)
1..sync 修饰符 2.3.0+ 新增 vue 修饰符sync的功能是:当一个子组件改变了一个 prop 的值时,这个变化也会同步到父组件中所绑定.类似于v-model的效果 例子: this.$ ...
- oracle中使用sql语句生成10w条测试数据
sql语句 create table AAAATest as select rownum as cardNo, 'test' creator, to_char(sysdate + rownum//, ...
- 小白学习安全测试(三)——扫描工具-Nikto使用
扫描工具-Nikto #基于WEB的扫描工具,基本都支持两种扫描模式.代理截断模式,主动扫描模式 手动扫描:作为用户操作发现页面存在的问题,但可能会存在遗漏 自动扫描:基于字典,提高速度,但存在误报和 ...
- 自己动手破解rar密码-ruby脚本实现
破解密码,上策是社工的方式,下策则是暴力破解了.这里使用暴力破解,字典文件放在txt中:通过调用winrar的相关参数进行操作.经过测试,当字典中密码为100个时,破解耗时8秒(个人配置:i5-321 ...