2
を使用してPHP経由で電子メールを送信することができません:私は安全性の低いアプリへのアクセス、DisplayUnlockCaptchaだけでなく、IMAPを有効にしているこれは私のemail.phpファイルであるSMTP
<?php
$to = "[email protected]";
$from = "[email protected]";
$subject="Email";
$body="hi";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => '[email protected]',
'password' => 'password'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
?>
。アカウントで2段階認証プロセスを有効にしていません。しかし、私はまだ次のエラーが発生します。
authentication failure [SMTP: Invalid response code received from server (code: 534, response: 5.7.14 Please log in via your web browser and 5.7.14 then try again. 5.7.14 Learn more at 5.7.14 https://support.google.com/mail/answer/78754 i28sm32905934pfk.17 - gsmtp)]
私はWindowsでXAMPPを使用していますが、これは私のphp.iniファイルに入れてきたものである:
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 465
; For Win32 only.
sendmail_from = [email protected]
誰かが私はこの問題を解決するのに役立つことができれば、私は非常に感謝されると思います!
あなたが右にキャプチャを入力してから10分以内にログインしていますか? – Oasa
私はxamppに慣れていません。しかし、私はあなたがphp-pearをインストールしていて、mail.phpがあなたの 'require'ステートメントにあることを願っています – Oasa