在 PHP 中使用 IMAP 的证书错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7891729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Certificate error using IMAP in PHP
提问by Shashank Jain
I used up all possible combinations of hostname but I always either get a certificate error or just IMAP connection broken.
我用完了所有可能的主机名组合,但我总是收到证书错误或只是 IMAP 连接中断。
Certificate failure for imap.froiden.com: Server name does not match certificate: /O=imap.mailhostbox.com/OU=Go to https://www.thawte.com/repository/index.html/OU=ThawteSSL123 certificate/OU=Domain Validated/CN=imap.mailhostbox.com
imap.froiden.com 的证书失败:服务器名称与证书不匹配:/O=imap.mailhostbox.com/OU=转到 https://www.thawte.com/repository/index.html/OU=ThawteSSL123 证书/OU=域验证/CN=imap.mailhostbox.com
Hostname which I used is '{imap.froiden.com}INBOX
'. ANy suggestion to solve this error?
我使用的主机名是“ {imap.froiden.com}INBOX
”。有什么建议可以解决这个错误吗?
回答by phihag
The certificate is plain invalid. You should either connect to imap.mailboxhost.com:993/imap/ssl
or contact the administrator of the mail server and ask for a valid certificate.
该证书是明显无效的。您应该连接到imap.mailboxhost.com:993/imap/ssl
或联系邮件服务器的管理员并要求提供有效的证书。
Note that while you canuse the connection string imap.froiden.com:993/imap/ssl/novalidate-cert
to skip certificate validation, you shouldnot do so as that flag will allow any Man In The Middleattacker to read and write your email.
请注意,虽然您可以使用连接字符串imap.froiden.com:993/imap/ssl/novalidate-cert
跳过证书验证,但您不应该这样做,因为该标志将允许任何中间人攻击者读取和编写您的电子邮件。
回答by Rok Megli?
I can confirm this is working well:
我可以确认这运行良好:
$mb = imap_open("{phoenix.srv.spletnasoba.si:993/imap/ssl/novalidate-cert}","username", "password" );
$emails = array();
$messageCount = imap_num_msg($mb);
for( $MID = 1; $MID <= $messageCount; $MID++ )
{
$EmailHeaders = imap_headerinfo( $mb, $MID );
foreach($EmailHeaders as $key => $value) {
if (validateEmail($value)) {
$emails[$value] = $key;
echo $value."\n";
}
}
}
function validateEmail($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
回答by abdul01
In case you're using gmail, make sure you turn on "Allow access for less secure apps" in the account settings page of your google account for you to be able to access your gmail account using imap_open()
如果您使用的是 Gmail,请确保在您的 Google 帐户的帐户设置页面中打开“允许访问不太安全的应用程序”,以便您能够使用 imap_open() 访问您的 Gmail 帐户