[英]send email using php with AWS EC2
I use AWS EC2 server (ubuntu instance) and I want to send email through php code 我使用AWS EC2服务器(ubuntu实例),我想通过php代码发送电子邮件
I installed sendmail and modify .mc file as blow 我安装了sendmail并将.mc文件修改为打击
FEATURE(`no_default_msa')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl
I removed Addr and restart sendmail service 我删除了Addr并重新启动sendmail服务
but, I cannot send an email. 但是,我无法发送电子邮件。
I tested sendmail on console (sendmail to@mail.com from@mail.com) 我在控制台上测试了sendmail(从@ mail.com发送到@ mail.com的邮件)
and php file like php sendmailtest.php. 和php文件,例如php sendmailtest.php。
both of them work! 他们两个都工作!
but, it still doesn't work when I tried with browser. 但是,当我尝试使用浏览器时,它仍然不起作用。 ( like http://test.com/sendmail.php )
(例如http://test.com/sendmail.php )
here is my apache log 这是我的Apache日志
sh: 1: sendmail: not found
[Thu Apr 25 03:40:53 2013] [error] [client xxx.xxx.xxx.xxx] xxx@gmail.com
[Thu Apr 25 03:40:54 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /var/www/favicon.ico
update 更新
here is my test code to send email 这是我发送电子邮件的测试代码
$mailto="xxxxxxxx@gmail.com";
$subject="mail test";
$content="test";
$result=mail($mailto, $subject, $content);
if($result){
echo "mail success";
}else {
error_log($mailto, 0);
echo "mail fail";
}
Thanks in advance, 提前致谢,
Solved this problem. 解决了这个问题。
I should input /usr/sbin/sendmail 我应该输入/ usr / sbin / sendmail
I don't know why another location doesn't work even there exists sendmail. 我不知道为什么即使存在sendmail,另一个位置也不起作用。
使用绝对路径发送sendmail,从脚本运行时,通常不会设置PATH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.