Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何修复';530-5.5.1需要认证';尝试从本地主机发送电子邮件时出错?_Php_Email_Smtp - Fatal编程技术网

Php 如何修复';530-5.5.1需要认证';尝试从本地主机发送电子邮件时出错?

Php 如何修复';530-5.5.1需要认证';尝试从本地主机发送电子邮件时出错?,php,email,smtp,Php,Email,Smtp,我一直在尝试从运行在本地主机上的以下PHP脚本发送电子邮件,其中G-mail作为SMTP中继主机 <?php // The message $message = "Line 1\r\nLine 2\r\nLine 3"; $message = wordwrap($message, 70, "\r\n"); $headers = 'From: <my-email>@gmail.com' . "\r\n" . 'Reply-To: <my-email>@gm

我一直在尝试从运行在本地主机上的以下PHP脚本发送电子邮件,其中G-mail作为SMTP中继主机

<?php
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";

$message = wordwrap($message, 70, "\r\n");

$headers = 'From: <my-email>@gmail.com' . "\r\n" .
    'Reply-To: <my-email>@gmail.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

// Send Mail
if (true==mail('<other email>@gmail.com', 'My Subject', $message, $headers, '-f<other email>@gmail.com'))
{
    echo "E-mail successfully sent.";
}
else
{
    echo "E-mail failed.";
}
?>
我注意到的一件事是,当我运行postmap创建
sasl\u passwd.db
文件时,我得到以下警告:

postmap: warning: sasl_passwd, line 0: expected format: key whitespace value
我确信我忽略了一些非常简单的问题,但我在过去几天里一直在努力让这个邮件功能发挥作用


提前感谢您的建议

事实证明,我需要配置我的Google Apps帐户,以便允许SMTP中继。一旦我这样做了,我就可以开始使用PHP中的phpMail和常规邮件功能发送电子邮件了。

Use。这让事情变得容易多了。谢谢!我试过使用PHPMailer,它真的很管用。
smtp.gmail.com:587 <my gmail account>:�<my gmail password>
#Gmail SMTP
relayhost = smtp.gmail.com:587
# Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=
# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom
smtp_tls_CAfile = /etc/postfix/ssl/cacert.pem
debug_peer_list=smtp.gmail.com
debug_peer_level=3
postmap: warning: sasl_passwd, line 0: expected format: key whitespace value