1

我正在使用 Ubuntu 19.10。我刚刚安装ssmtp并重新配置了https://www.nixtutor.com/linux/send-mail-with-gmail-and-ssmtp//etc/ssmtp/ssmtp.conf中给出的文件 所以我的/etc/ssmtp/ssmtp.conf看起来像 -

# Make this empty to disable rewriting.
root=demo@gmail.com

# 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.gmail.com:587
# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=127.0.1.1:80
UseSTARTTLS=YES
AuthUser=demo@gmail.com
AuthPass=123456

# 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

php.ini中的邮件路径
sendmail_path /usr/sbin/sendmail -t -i

和用于发送邮件的自定义 php 脚本send_mail.php -

<?php
  // the message
  $msg = 'Testing for send mail in Linux';
  // send email
  $send = mail('demo@gmail.com','My subject',$msg);
  echo $send ?  'MAIL SENT' : 'MAIL NOT SENT';
?>

通过浏览器运行时的
输出 MAIL NOT SENT
通过终端运行时的输出 ( php send_mail.php )
sendmail: (127.0.1.1:80)
MAIL NOT SENT

请帮帮我!

4

0 回答 0