linux学习 之 ubuntu下用postfix搭建邮件服务器

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 [email protected]

喔喔,出现问题:

 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 [email protected] //发信人邮箱

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 "邮件标题" [email protected]

测试成功,可以收到。

现在发送附件:

echo "This is the message body" | mail -s "subject" [email protected] -a /xx/xx/xx




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章