如何使用PHP Pear Mail发送邮件。我在demo.php文件中使用以下代码:
$options = array();
//Setting for configration of mail server SMTP
$options['host'] = 'ssl://smtp.gmail.com';
$options['port'] = '465';
$options['auth'] = true;
$options['username'] = 'username@gmail.com';
$options['password'] = 'mypassword';
$mailer = Mail::factory('smtp',$options);
$headers = array();
$headers['From'] = 'username@gmail.com';
$headers['To'] = 'recipiet@gmail.com';
$headers['Subject'] = 'Learn sent mail with php';
//List of recipiets
$recipiet= 'recipiets@gmail.com';
$body = '<b>I love you</b>';
//Sent mail
$result = $mailer->send($recipiet,$headers,$body);
if(PEAR::isError($result)){
$error = $result->getMessage();
echo htmlspecialchars($error);
}
但显示身份验证失败[SMTP:从服务器收到无效的响应代码(代码:534,响应:5.7.14请通过网络浏览器登录,5.7.14然后再试一次.5.7.14了解详情在5.7.14 https://support.google.com/mail/answer/78754 y184sm509718pfg.94 - gsmtp)] 帮帮我!!!