Centos下直接在/etc/mail.rc下配置就可以发送文件了
set from=abc@163.com smtp=smtp.163.com smtp-auth-user=abc@163.com smtp-auth-password=passwd smtp-auth=login
再ubuntu下可以安装ssmtp来实现邮件的发送
首先安装ssmtp
aptitude install ssmtp mailutils
然后再/etc/ssmtp目录下配置
ssmtp.conf的配置文件
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=自己邮箱地址
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=邮箱smtp服务器地址
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=主机名
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
AuthUser=邮箱地址
AuthPass=邮箱密码
Revaliases文件的配置
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:自己的邮箱:邮箱smtp服务器地址:端口 (如果这里写root,那么只有root用户有权限使用,其他用户使用会报错cannot send message: Process exited with a non-zero status )
#如自己的邮箱是腾讯的企业邮箱:
#root:自己邮箱:imap.exmail.qq.com:465
配置完成后之后用 mail abc@163.com 发送邮件了
在这里我遇到过一个问题,mail时报错 cannot send message: Process exited with a non-zero status
检查之后发现是我把邮箱密码写错了,修改之后不再报错
如果报这个错有以下可能
1.配置文件写的不正确
2.安装了sendmail之类的邮件服务没有关闭,会导致冲突
3.没有使用root权限来运行mail