我的服务器没有“postfix”来从“sendmail”发送邮件。
相反,我使用“msmtp”和“s-nail”shell 命令。
它在交互式 shell('bash')中运行良好。
我尝试从 PHP 发送邮件,但我没有收到任何邮件,也没有输出也没有错误:
<?php
$mess = 'foobar';
$to = '[email protected]';
$subject = 'test';
//mail($to,$subject,$mess); doesn't work
$out = system("echo $mess | /usr/bin/s-nail -v -s $subject $to");
echo $out;
?>
有什么帮助吗?
如果我这样运行脚本:
# php script.php
有效。
但是从网络调用时,它不起作用
在那里找到解决方案:https://wiki.archlinux.org/title/Msmtp#Miscellaneous
在“php.ini”中:
sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t"
在
/etc/mail.rc
:
set mta=/usr/bin/msmtp
在PHP脚本中,现在
mail()
正常运行