在命令行上 Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在命令行上 Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1916字,纯文字阅读大概需要3分钟。
内容图文
![在命令行上 Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件](/upload/InfoBanner/zyjiaocheng/1311/73ebbd94421c4ac996e0efc243892f78.jpg)
在命令行写email from ubuntu
参考:
http://www.habadog.com/2011/11/23/send-mail-with-msmtp-mutt-linux
http://www.absolutelytech.com/2010/07/17/howto-configure-msmtp-to-work-with-gmail-on-linux
msmtp 是一款专门负责邮件发送的客户端软件,基于GPL发布,支持TLS/SSL、DNS模式、IPv6、服务器端认证、多用户等特性。
其主页是 msmtp.sourceforge.net:
Msmtp is an SMTP client with a sendmail compatible interface ...
安装
sudo apt-get install mutt msmtp
如需要对TLS/SSL的支持,还需要安装 GnuTLS 或者 OpenSSL,官方推荐 GnuTLS (https://help.ubuntu.com/community/GnuTLS):
sudo apt-get install gnutls-bin
另外,使用 Gmail 需要安装 ca-certificates:
sudo apt-get install ca-certificates
msmtp 有 3 中工作模式:
Sendmail mode (default)
Server information mode
Remote Message Queue Starting mode
对于发送邮件来说,使用 Sendmail mode (default) 就可以了:
In the default sendmail mode, msmtp reads a mail from standard input and sends it to an SMTP server for delivery.
配置 msmtp
安装完后,编辑 msmtp 配置文件 ~/.msmtprc
defaults tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt account default host smtp.gmail.com port 587 auth on user username@gmail.com password mypass from username@gmail.com logfile ~/msmtp.log
把 username@gmail.com 和 mypass 替换成实际的邮箱和密码就可以了,这里密码是明文。注意,发送邮件默认是 25 端口,但是 Gmail 邮件服务商用的不是 25 端口,而是 465 或 587 端口。如果不设置端口,发送邮件会报错 "Must issue a STARTTLS command first"。logfile 如果设置的时候要注意设置访问权限,保证当前用户可写。
保存后,修改访问权限
chmod 0600 .msmtprc
如果不这样,会报错:
must have no more than user read/write permissions
测试发送邮件:
msmtp XXX@example.com
输入任意字符,然后按Ctrl+D退出,查看邮件是否收到。可以查看 logfile 里面的发送日志记录。
配置 mutt
查看 msmtp 安装路径
$ which msmtp
/usr/bin/msmtp
编辑 mutt 配置文件 ~/.muttrc
set sendmail="/path/to/msmtp" set use_from=yes set realname="Your Name" set from=you@example.com set envelope_from=yes set editor="vim"
后面就可以用 mutt 写邮件后通过 msmtp 发送了。
小结
对于 msmtp 的详细介绍,可以参考 http://msmtp.sourceforge.net/documentation.html 或者 man msmtp。
文档里面提供了配置示例,包括 msmtp 配合 mutt 的配置。
原文:http://www.cnblogs.com/chjbbs/p/6389261.html
内容总结
以上是互联网集市为您收集整理的在命令行上 Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件全部内容,希望文章能够帮你解决在命令行上 Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。