PHP GMail IMAP 连接失败
PHP GMail IMAP Connection Failure
我正在使用这个 repo 连接到 gmail。但它越来越错误。我希望最近有人有处理这个的经验。
<?php
namespace program;
require_once "php-imap-client/vendor/autoload.php";
use SSilence\ImapClient\ImapClientException;
use SSilence\ImapClient\ImapConnect;
use SSilence\ImapClient\ImapClient as Imap;
$mailbox = 'imap.gmail.com';
$username = 'alice@gmail.com';
$password = "wonderland";
$encryption = Imap::ENCRYPT_SSL;
// Open connection
try{
$imap = new Imap($mailbox, $username, $password, $encryption);
// You can also check out example-connect.php for more connection options
}catch (ImapClientException $error){
echo $error->getMessage().PHP_EOL;
die(); // Oh no :( we failed
}
我以前也遇到过。来自您收到的错误消息中的 link。
Allow less secure apps: If you don't use 2-Step Verification, you
might need to allow less secure apps to access your account.
我正在使用这个 repo 连接到 gmail。但它越来越错误。我希望最近有人有处理这个的经验。
<?php
namespace program;
require_once "php-imap-client/vendor/autoload.php";
use SSilence\ImapClient\ImapClientException;
use SSilence\ImapClient\ImapConnect;
use SSilence\ImapClient\ImapClient as Imap;
$mailbox = 'imap.gmail.com';
$username = 'alice@gmail.com';
$password = "wonderland";
$encryption = Imap::ENCRYPT_SSL;
// Open connection
try{
$imap = new Imap($mailbox, $username, $password, $encryption);
// You can also check out example-connect.php for more connection options
}catch (ImapClientException $error){
echo $error->getMessage().PHP_EOL;
die(); // Oh no :( we failed
}
我以前也遇到过。来自您收到的错误消息中的 link。
Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.