1,安装 postfix

sudo apt-get install postfix

安装postfix,配置界面出来后选择Internet Site,System mail name填写 名称

2,安装一个 mailx 用于测试

sudo apt-get install mailx

err

sudo: unable to resolve host iZwz9aig3cb8oqsp6dy3gvZ
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package mailx is a virtual package provided by:
  s-nail 14.8.6-1
  mailutils 1:2.99.99-1ubuntu2
  bsd-mailx 8.1.2-0.20160123cvs-2
You should explicitly select one to install.


E: Package 'mailx' has no installation candidate

选择第二项来安装,即heirloom-mailx:

sudo apt-get install heirloom-mailx

安装好之后,测试 发送邮件

echo "test"|mail hqj1995@qq.com

喔喔,出现问题:

 postdrop: warning: unable to look up public/pickup: No such file or directory

报错原因:

与Debian Linux VPS 6,你可能得到Sendmail MTA违约。如果你已经安装和配置后缀这可能导致错误。
如果您执行“echo|mail your.com”在本地配置(your.com)你会看到下面的错误出现:
postdrop:warning: unable to look up public/pickup: No such file or directory

解决办法:

关闭sendmail(如果有)然后开启postfix即可!

/etc/init.d/sendmail stop

/etc/init.d/postfix start

ps aux|grep postfix


当然,还有一个很重要的点,就是配置mailx (Ubuntu中 etc/s-nail.rc //其他系统中可能叫nail.rc 或 mail.rc

vim /etc/s-nail.rc

set from=USER@qq.com //发信人邮箱

set smtp=smtps://smtp.qq.com:465 //发信人邮箱的SMTP地址

set smtp-auth-user=USER //发信人邮箱登陆账号

set smtp-auth-password=PASSWORD //发信人邮箱系统提供的授权码

set smtp-auth=login

 echo"邮件内容" | mail -vs "邮件标题" XX@126.com

测试成功,可以收到。

现在发送附件:

echo "This is the message body" | mail -s "subject" XX@126.com -a /xx/xx/xx




Logo

更多推荐