本文整理汇总了PHP中imap_timeout函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_timeout函数的具体用法?PHP imap_timeout怎么用?PHP imap_timeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_timeout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initImapStream
/**
* @return resource
* @throws MailboxException
*/
protected function initImapStream()
{
imap_timeout(IMAP_OPENTIMEOUT, 15);
$imapStream = @imap_open($this->imapFullPath, $this->settings['user'], $this->settings['password'], $this->imapOptions, $this->imapRetriesNum, $this->imapParams);
if (!$imapStream) {
throw new MailboxException();
}
return $imapStream;
}
示例2: __construct
/**
* Opens an IMAP stream
*/
public function __construct()
{
// Set Imap Timeouts
imap_timeout(IMAP_OPENTIMEOUT, 90);
imap_timeout(IMAP_READTIMEOUT, 90);
// If SSL Enabled
$ssl = Kohana::config('settings.email_ssl') == true ? "/ssl" : "";
// Do not validate certificates (TLS/SSL server)
//$novalidate = strtolower(Kohana::config('settings.email_servertype')) == "imap" ? "/novalidate-cert" : "";
$novalidate = "/novalidate-cert";
// If POP3 Disable TLS
$notls = strtolower(Kohana::config('settings.email_servertype')) == "pop3" ? "/notls" : "";
/*
More Info about above options at:
http://php.net/manual/en/function.imap-open.php
*/
$service = "{" . Kohana::config('settings.email_host') . ":" . Kohana::config('settings.email_port') . "/" . Kohana::config('settings.email_servertype') . $notls . $ssl . $novalidate . "}";
// Check if the host name is valid, if not, set imap_stream as false and return false
if (count(dns_get_record("" . Kohana::config('settings.email_host') . "")) == 0) {
$this->imap_stream = false;
return false;
}
if ($imap_stream = @imap_open($service, Kohana::config('settings.email_username'), Kohana::config('settings.email_password'))) {
$this->imap_stream = $imap_stream;
} else {
// We don't usually want to break the entire scheduler process if email settings are off
// so lets return false instead of halting the entire script with a Kohana Exception.
$this->imap_stream = false;
return false;
//throw new Kohana_Exception('imap.imap_stream_not_opened', $throwing_error);
}
}
示例3: open
public function open()
{
$this->baseMailbox = '{' . $this->host . ':' . $this->port . '/' . $this->type;
if (in_array($this->security, ['ssl', 'tls'])) {
$this->baseMailbox .= '/' . $this->security;
}
if ($this->validateCertificate !== null) {
if ($this->validateCertificate) {
$this->baseMailbox .= '/validate-cert';
} else {
$this->baseMailbox .= '/novalidate-cert';
}
}
$this->baseMailbox .= '}INBOX';
imap_timeout(IMAP_OPENTIMEOUT, 3);
imap_timeout(IMAP_READTIMEOUT, 3);
imap_timeout(IMAP_WRITETIMEOUT, 3);
imap_timeout(IMAP_CLOSETIMEOUT, 3);
ini_set('default_socket_timeout', 3);
//error_reporting(0);
$this->connection = imap_open($this->baseMailbox, $this->username, $this->password, 0, 1);
/*if(! $this->connection)
{
var_dump($this->baseMailbox);
}*/
//error_reporting(-1);
return !$this->connection;
}
示例4: imap_test_connect
function imap_test_connect($host,$user,$pass,$timeout=-1,$protocol="imap",$port=-1,$ssl=false,$debug=false)
{
global $NATS;
if ($timeout>0) $timeout=$timeout; // use specific for test if set
else
{
// otherwise use system if available
if (isset($NATS)) $timeout=$NATS->Cfg->Get("test.imap.timeout",0);
if ($timeout<=0) $timeout=0; // unset specifically or in environment
}
if ($timeout>0) imap_timeout(IMAP_OPENTIMEOUT,$timeout);
if ($port<=0)
{
$port=143; // default
if ( ($protocol=="imap") && ($ssl) ) $port=993;
else if ($protocol=="pop3")
{
if ($ssl) $port=995;
else $port=110;
}
}
$mailbox="{".$host.":".$port."/service=".$protocol;
if ($ssl) $mailbox.="/ssl";
$mailbox.="/novalidate-cert";
$mailbox.="}INBOX";
if ($debug) echo $user.":".$pass."@".$mailbox."\n";
$imap=@imap_open($mailbox,$user,$pass);
if ($imap===false) return 0;
@imap_close($imap);
return 1;
}
示例5: connect
/**
* @param Mirasvit_Helpdesk_Model_Gateway $gateway
*
* @return bool
*/
public function connect($gateway)
{
$this->gateway = $gateway;
$flags = sprintf('/%s', $gateway->getProtocol());
if ($gateway->getEncryption() == 'ssl') {
$flags .= '/ssl';
}
$flags .= '/novalidate-cert';
// echo $flags;die;
$server = new Mirasvit_Ddeboer_Imap_Server($gateway->getHost(), $gateway->getPort(), $flags);
if (function_exists('imap_timeout')) {
imap_timeout(1, 20);
}
if (!($this->connection = $server->authenticate($gateway->getLogin(), $gateway->getPassword()))) {
return false;
}
$mailboxes = $this->connection->getMailboxNames();
if (in_array('INBOX', $mailboxes)) {
$mailboxName = 'INBOX';
} elseif (in_array('Inbox', $mailboxes)) {
$mailboxName = 'Inbox';
} else {
$mailboxName = $mailboxes[0];
}
$this->mailbox = $this->connection->getMailbox($mailboxName);
return true;
}
示例6: MailFetcher
function MailFetcher($username,$password,$hostname,$port,$protocol,$encryption='') {
if(!strcasecmp($protocol,'pop')) //force pop3
$protocol='pop3';
$this->hostname=$hostname;
$this->username=$username;
$this->password=$password;
$this->protocol=strtolower($protocol);
$this->port = $port;
$this->encryption = $encryption;
$this->serverstr=sprintf('{%s:%d/%s',$this->hostname,$this->port,strtolower($this->protocol));
if(!strcasecmp($this->encryption,'SSL')){
$this->serverstr.='/ssl';
}
$this->serverstr.='/novalidate-cert}INBOX'; //add other flags here as needed.
//echo $this->serverstr;
//Charset to convert the mail to.
$this->charset='UTF-8';
//Set timeouts
if(function_exists('imap_timeout'))
imap_timeout(1,20); //Open timeout.
}
示例7: download_and_process_email_replies
/**
* Primary method for downloading and processing email replies
*/
public function download_and_process_email_replies($connection_details)
{
imap_timeout(IMAP_OPENTIMEOUT, apply_filters('supportflow_imap_open_timeout', 5));
$ssl = $connection_details['imap_ssl'] ? '/ssl' : '';
$ssl = apply_filters('supportflow_imap_ssl', $ssl, $connection_details['imap_host']);
$mailbox = "{{$connection_details['imap_host']}:{$connection_details['imap_port']}{$ssl}}";
$inbox = "{$mailbox}{$connection_details['inbox']}";
$archive_box = "{$mailbox}{$connection_details['archive']}";
$imap_connection = imap_open($mailbox, $connection_details['username'], $connection_details['password']);
$redacted_connection_details = $connection_details;
$redacted_connection_details['password'] = '[redacted]';
// redact the password to avoid unnecessarily exposing it in logs
$imap_errors = imap_errors();
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $imap_connection ? __('Successfully opened IMAP connection.', 'supportflow') : __('Failed to open IMAP connection.', 'supportflow'), compact('redacted_connection_details', 'mailbox', 'imap_errors'));
if (!$imap_connection) {
return new WP_Error('connection-error', __('Error connecting to mailbox', 'supportflow'));
}
// Check to see if the archive mailbox exists, and create it if it doesn't
$mailboxes = imap_getmailboxes($imap_connection, $mailbox, '*');
if (!wp_filter_object_list($mailboxes, array('name' => $archive_box))) {
imap_createmailbox($imap_connection, $archive_box);
}
// Make sure here are new emails to process
$email_count = imap_num_msg($imap_connection);
if ($email_count < 1) {
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('No new messages to process.', 'supportflow'), compact('mailboxes'));
return false;
}
$emails = imap_search($imap_connection, 'ALL', SE_UID);
$email_count = min($email_count, apply_filters('supportflow_max_email_process_count', 20));
$emails = array_slice($emails, 0, $email_count);
$processed = 0;
// Process each new email and put it in the archive mailbox when done.
foreach ($emails as $uid) {
$email = new stdClass();
$email->uid = $uid;
$email->msgno = imap_msgno($imap_connection, $email->uid);
$email->headers = imap_headerinfo($imap_connection, $email->msgno);
$email->structure = imap_fetchstructure($imap_connection, $email->msgno);
$email->body = $this->get_body_from_connection($imap_connection, $email->msgno);
if (0 === strcasecmp($connection_details['username'], $email->headers->from[0]->mailbox . '@' . $email->headers->from[0]->host)) {
$connection_details['password'] = '[redacted]';
// redact the password to avoid unnecessarily exposing it in logs
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('Skipping message because it was sent from a SupportFlow account.', 'supportflow'), compact('email'));
continue;
}
// @todo Confirm this a message we want to process
$result = $this->process_email($imap_connection, $email, $email->msgno, $connection_details['username'], $connection_details['account_id']);
// If it was successful, move the email to the archive
if ($result) {
imap_mail_move($imap_connection, $email->uid, $connection_details['archive'], CP_UID);
$processed++;
}
}
imap_close($imap_connection, CL_EXPUNGE);
$status_message = sprintf(__('Processed %d emails', 'supportflow'), $processed);
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $status_message);
return $status_message;
}
示例8: __construct
public function __construct($mailbox, $username, $password, $timeout = 30)
{
imap_timeout(IMAP_OPENTIMEOUT, $timeout);
imap_timeout(IMAP_READTIMEOUT, $timeout);
imap_timeout(IMAP_WRITETIMEOUT, $timeout);
try {
$this->count = imap_num_msg($this->imap = imap_open(\Zeyon\convert($mailbox, 'UTF7-IMAP'), \Zeyon\convert($username, 'UTF7-IMAP'), \Zeyon\convert($password, 'UTF7-IMAP'), OP_SILENT, 1));
} catch (\Exception $e) {
throw new \Exception('IMAP: ' . (($error = imap_last_error()) === false ? $e->getMessage() : $error));
}
}
示例9: __construct
/**
* Opens an IMAP stream
*/
public function __construct()
{
// Set Imap Timeouts
imap_timeout(IMAP_OPENTIMEOUT, 90);
imap_timeout(IMAP_READTIMEOUT, 90);
$ssl = Kohana::config('settings.email_ssl') == true ? "ssl/novalidate-cert" : "";
$service = "{" . Kohana::config('settings.email_host') . ":" . Kohana::config('settings.email_port') . "/" . Kohana::config('settings.email_servertype') . "/" . $ssl . "}";
$imap_stream = imap_open($service, Kohana::config('settings.email_username'), Kohana::config('settings.email_password'));
if (!$imap_stream) {
throw new Kohana_Exception('imap.imap_stream_not_opened', imap_last_error());
}
$this->imap_stream = $imap_stream;
}
示例10: __construct
/**
* Opens an IMAP stream
*/
public function __construct()
{
// Set Imap Timeouts
imap_timeout(IMAP_OPENTIMEOUT, 90);
imap_timeout(IMAP_READTIMEOUT, 90);
$config = Kohana::config('email');
$ssl = $config['ssl'] == true ? "ssl/novalidate-cert" : "";
$service = "{" . $config['server'] . ":" . $config['port'] . "/" . $config['servertype'] . "/" . $ssl . "}";
$imap_stream = imap_open($service, $config['username'], $config['password']);
if (!$imap_stream) {
throw new Kohana_Exception('imap.imap_stream_not_opened', imap_last_error());
}
$this->imap_stream = $imap_stream;
}
示例11: __construct
/**
* constructor
*
* @param CSourcePOP $source Source POP
*/
function __construct($source)
{
//stock the source
$this->source = $source;
if (!function_exists("imap_open")) {
CModelObject::error("FE-IMAP-support-not-available");
}
//initialise open TIMEOUT
imap_timeout(1, $this->source->timeout);
//lets create the string for stream
$type = $this->source->type == "pop3" ? "/" . $this->source->type : "";
$ssl = $this->source->auth_ssl == "SSL/TLS" ? "/ssl/novalidate-cert" : "/notls";
$port = $this->source->port ? ":" . $this->source->port : "";
$extension = $this->source->extension ? $this->source->extension : "";
return $this->_server = "{" . $this->source->host . $port . $type . $ssl . "}" . $extension;
}
示例12: connect
function connect()
{
ob_start();
$buff = imap_alerts();
$buff = imap_errors();
$timeout = $this->config->get('bounce_timeout');
if (!empty($timeout)) {
imap_timeout(IMAP_OPENTIMEOUT, $timeout);
}
$port = $this->config->get('bounce_port', '');
$secure = $this->config->get('bounce_secured', '');
$protocol = $this->config->get('bounce_connection', '');
$serverName = '{' . $this->config->get('bounce_server');
if (empty($port)) {
if ($secure == 'ssl' && $protocol == 'imap') {
$port = '993';
} elseif ($protocol == 'imap') {
$port = '143';
} elseif ($protocol == 'pop3') {
$port = '110';
}
}
if (!empty($port)) {
$serverName .= ':' . $port;
}
if (!empty($secure)) {
$serverName .= '/' . $secure;
}
if ($this->config->get('bounce_certif', false)) {
$serverName .= '/novalidate-cert';
}
if (!empty($protocol)) {
$serverName .= '/service=' . $protocol;
}
$serverName .= '}';
$this->mailbox = imap_open($serverName, $this->config->get('bounce_username'), $this->config->get('bounce_password'));
$warnings = ob_get_clean();
if (!empty($warnings) && $this->report) {
acymailing::display($warnings, 'warning');
}
return $this->mailbox ? true : false;
}
示例13: MailFetcher
function MailFetcher($email, $charset = 'UTF-8')
{
if ($email && is_numeric($email)) {
//email_id
$email = Email::lookup($email);
}
if (is_object($email)) {
$this->ht = $email->getMailAccountInfo();
} elseif (is_array($email) && $email['host']) {
//hashtable of mail account info
$this->ht = $email;
} else {
$this->ht = null;
}
$this->charset = $charset;
if ($this->ht) {
if (!strcasecmp($this->ht['protocol'], 'pop')) {
//force pop3
$this->ht['protocol'] = 'pop3';
} else {
$this->ht['protocol'] = strtolower($this->ht['protocol']);
}
//Max fetch per poll
if (!$this->ht['max_fetch'] || !is_numeric($this->ht['max_fetch'])) {
$this->ht['max_fetch'] = 20;
}
//Mail server string
$this->srvstr = sprintf('{%s:%d/%s', $this->getHost(), $this->getPort(), $this->getProtocol());
if (!strcasecmp($this->getEncryption(), 'SSL')) {
$this->srvstr .= '/ssl';
}
$this->srvstr .= '/novalidate-cert}';
}
//Set timeouts
if (function_exists('imap_timeout')) {
imap_timeout(1, 20);
}
}
示例14: __construct
/**
* Opens an IMAP stream
*/
public function __construct()
{
// Set Imap Timeouts
imap_timeout(IMAP_OPENTIMEOUT, 90);
imap_timeout(IMAP_READTIMEOUT, 90);
// If SSL Enabled
$ssl = Kohana::config('settings.email_ssl') == true ? "/ssl" : "";
// Do not validate certificates (TLS/SSL server)
//$novalidate = strtolower(Kohana::config('settings.email_servertype')) == "imap" ? "/novalidate-cert" : "";
$novalidate = "/novalidate-cert";
// If POP3 Disable TLS
$notls = strtolower(Kohana::config('settings.email_servertype')) == "pop3" ? "/notls" : "";
/*
More Info about above options at:
http://php.net/manual/en/function.imap-open.php
*/
$service = "{" . Kohana::config('settings.email_host') . ":" . Kohana::config('settings.email_port') . "/" . Kohana::config('settings.email_servertype') . $notls . $ssl . $novalidate . "}";
$imap_stream = imap_open($service, Kohana::config('settings.email_username'), Kohana::config('settings.email_password'));
if (!$imap_stream) {
throw new Kohana_Exception('imap.imap_stream_not_opened', imap_last_error());
}
$this->imap_stream = $imap_stream;
}
示例15: explode
$download_data = explode("::", base64_decode($_POST["download_data"]));
$download_dir = $_POST["download_dir"];
//print_r($download_data);
$mbox_name = $download_data[0];
$use_ssl = $download_data[1];
$validate_cert = $download_data[2];
$username = $download_data[3];
$password = $download_data[4];
$use_tls = $download_data[5];
$folder = $download_data[6];
$msg_number = (int) $download_data[7];
$attachment_name = $download_data[8];
imap_timeout(15, IMAP_OPENTIMEOUT);
imap_timeout(15, IMAP_READTIMEOUT);
imap_timeout(15, IMAP_WRITETIMEOUT);
imap_timeout(15, IMAP_CLOSETIMEOUT);
$use_ssl_flag = $use_ssl == "true" ? "/ssl" : "";
$validate_cert_flag = $validate_cert == "true" ? "" : "/novalidate-cert";
$use_tls_flag = $use_tls == "true" ? "/tls" : "";
$mbox = imap_open("{" . $mbox_name . $use_ssl_flag . $validate_cert_flag . $use_tls_flag . "}{$folder}", $username, $password);
//print_r(imap_errors());
$message = new MailMessage($mbox, $msg_number);
//print_r($message);
$attachments = $message->getAttachments();
//print_r($attachments);
$download_data = null;
if ($attachment_name == '*') {
if (class_exists("ZipArchive")) {
$attachment_name = "{$download_dir}/attachments-{$msg_number}.zip";
$zip = new ZipArchive();
$zip->open($attachment_name, ZipArchive::CREATE);