gpt4 book ai didi

php - 如何使用安全的 POP3 服务器覆盖 imap_timeout 功能的 php.ini 超时

转载 作者:可可西里 更新时间:2023-11-01 12:37:16 24 4
gpt4 key购买 nike

PHP IMAP 库没有内置方法来更改安全 pop3 连接的 imap_timeout 函数。我正在寻求构建此功能,以便我可以将安全 pop3 服务器的连接超时设置为 1 秒,但我只是不确定从哪里开始学习如何在 PHP 函数中覆盖 php.ini 命令。有任何想法吗?

imap_timeout(1, ) works fine for pop3 connections, but apparently not for pop3s (ssl, port 995) connections, where the default socket timeout still applies. This applies to php 4.3.10, not tested on other versions.


We looked into the source to find out what this function actually does and how to use it. The function overrides the default_socket_timeout setting from your php.ini file

You can retrieve the current timeout length for each timeout type by calling the function as:

imap_timeout(timeout_type); or imap_timeout(timeout_type,-1);

You can set the timeout length for any of the timeout types by setting the timeout value to a number of seconds.

imap_timeout(timeout_type,);

The timeout types are as follows:

1: Open 2: Read 3: Write 4: Close

It does not appear that the close type has been implemented.

来源:https://students.kiv.zcu.cz/doc/php5/manual/cs/function.imap-timeout.php.html

最佳答案

使用default_socket_timeout

这里是覆盖默认配置的小演示。

ini_set('default_socket_timeout', 2);
// your socket based code here

// restore to the default socket timeout
ini_restore('default_socket_timeout');

关于php - 如何使用安全的 POP3 服务器覆盖 imap_timeout 功能的 php.ini 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5969489/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com