Amazon有后缀和sendmail的说明,但没有msmtp(简单SMTP客户端),所以在这里添加它们。
安装msmtp (ubuntu)
sudo apt-get install msmtp msmtp-mta
Configure it (sudo nano /etc/msmtprc
):
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
syslog on
account default
host email-smtp.us-east-1.amazonaws.com
port 587
auth on
user YOUR_AMAZON_SES_SMTP_USERNAME
password YOUR_AMAZON_SES_SMTP_PASSWORD
from YOUR_AMAZON_SES_VERIFIED_SENDER
使用它。你不需要用服务器信息设置PHP;默认配置将把消息传递给sendmail,这样就可以了。
<?php
mail("user@example.com", "some subject", "some message");
?>
如果不使用PHP,可以在命令行上进行测试:
$ sendmail test-recipient@example.com
Subject: test subject
This is a test message!
^D
(^D
表示输入control-D停止输入消息并发送消息)