• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imap_open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imap_open函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_open函数的具体用法?PHP imap_open怎么用?PHP imap_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imap_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: readEmails

 public function readEmails($sentTo = null, $bodyPart = null)
 {
     $host = '{imap.gmail.com:993/imap/ssl}INBOX';
     $spinner = new Spinner('Could not connect to Imap server.', 60, 10000);
     $inbox = $spinner->assertBecomesTrue(function () use($host) {
         return @imap_open($host, $this->email, $this->password);
     });
     $emails = imap_search($inbox, 'TO ' . ($sentTo ? $sentTo : $this->email));
     if ($emails) {
         $messages = [];
         foreach ($emails as $n) {
             $structure = imap_fetchstructure($inbox, $n);
             if (!$bodyPart) {
                 $part = $this->findPart($structure, function ($part) {
                     return $part->subtype === 'HTML';
                 });
             } elseif (is_callable($bodyPart)) {
                 $part = $this->findPart($structure, $bodyPart);
             } else {
                 $part = $bodyPart;
             }
             $hinfo = imap_headerinfo($inbox, $n);
             $subject = $hinfo->subject;
             $message = ['subject' => $subject, 'body' => imap_fetchbody($inbox, $n, $part)];
             $messages[] = $message;
         }
         return $messages;
     } else {
         return [];
     }
 }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:31,代码来源:GmailReader.php


示例2: connect

 /**
  *Opens a connection to the server
  *@return boolean
  */
 function connect($server, $port, $login, $password)
 {
     $option = "/service=" . $this->_protocol;
     if ($this->_ssl) {
         $option .= "/ssl";
     }
     if ($this->_tls_on) {
         $option .= "/tls";
     } else {
         $option .= "/notls";
     }
     if ($this->_self_cert) {
         $option .= "/novalidate-cert";
     }
     if (eregi("google", $server)) {
         //Fix from Jim Hodgson http://www.jimhodgson.com/2006/07/19/postie/
         $server_string = "{" . $server . ":" . $port . $option . "}INBOX";
     } else {
         $server_string = "{" . $server . ":" . $port . $option . "}";
     }
     $this->_connection = imap_open($server_string, $login, $password);
     if ($this->_connection) {
         $this->_connected = true;
     }
     return $this->_connected;
 }
开发者ID:robfelty,项目名称:postie,代码行数:30,代码来源:postieIMAP.php


示例3: emailDeliverFailBySubject

 public static function emailDeliverFailBySubject($subject)
 {
     $mailcnf = "outlook.office365.com:993/imap/ssl/novalidate-cert";
     $username = MAILACCOUNT;
     $pw = MAILPASSWORD;
     $conn_str = "{" . $mailcnf . "}INBOX";
     $inbox = imap_open($conn_str, $username, $pw) or die('Cannot connect to mail: ' . imap_last_error());
     /* grab emails */
     $emails = imap_search($inbox, 'SUBJECT "Undeliverable: ' . $subject . '"');
     $failedInfo = [];
     /* if emails are returned, cycle through each... */
     if ($emails) {
         /* for every email... */
         foreach ($emails as $email_number) {
             /* get information specific to this email */
             $body = imap_fetchbody($inbox, $email_number, 2);
             $list = split('; ', $body);
             $sender = $list[2];
             $sender_email = explode("\n", $sender)[0];
             array_push($failedInfo, trim($sender_email));
         }
     }
     /* close the connection */
     imap_close($inbox);
     return $failedInfo;
 }
开发者ID:aanyun,项目名称:PHP-Sample-Code,代码行数:26,代码来源:EmailController.php


示例4: authenticate

 function authenticate($username, $passwd)
 {
     error_reporting(error_reporting() - 2);
     if ($GLOBALS['phpgw_info']['server']['mail_login_type'] == 'vmailmgr') {
         $username = $username . '@' . $GLOBALS['phpgw_info']['server']['mail_suffix'];
     }
     if ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'imap') {
         $GLOBALS['phpgw_info']['server']['mail_port'] = '143';
     } elseif ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'pop3') {
         $GLOBALS['phpgw_info']['server']['mail_port'] = '110';
     } elseif ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'imaps') {
         $GLOBALS['phpgw_info']['server']['mail_port'] = '993';
     } elseif ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'pop3s') {
         $GLOBALS['phpgw_info']['server']['mail_port'] = '995';
     }
     if ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'pop3') {
         $mailauth = imap_open('{' . $GLOBALS['phpgw_info']['server']['mail_server'] . '/pop3' . ':' . $GLOBALS['phpgw_info']['server']['mail_port'] . '}INBOX', $username, $passwd);
     } elseif ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'imaps') {
         // IMAPS support:
         $mailauth = imap_open('{' . $GLOBALS['phpgw_info']['server']['mail_server'] . "/ssl/novalidate-cert" . ':993}INBOX', $username, $passwd);
     } elseif ($GLOBALS['phpgw_info']['server']['mail_server_type'] == 'pop3s') {
         // POP3S support:
         $mailauth = imap_open('{' . $GLOBALS['phpgw_info']['server']['mail_server'] . "/ssl/novalidate-cert" . ':995}INBOX', $username, $passwd);
     } else {
         /* assume imap */
         $mailauth = imap_open('{' . $GLOBALS['phpgw_info']['server']['mail_server'] . ':' . $GLOBALS['phpgw_info']['server']['mail_port'] . '}INBOX', $username, $passwd);
     }
     error_reporting(error_reporting() + 2);
     if ($mailauth == False) {
         return False;
     } else {
         imap_close($mailauth);
         return True;
     }
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:35,代码来源:class.auth_mail.inc.php


示例5: connect

 /**
  * Make a connect with a imap or pop3 mail server
  *
  * @param array $params Parameters for making connection
  */
 function connect($params)
 {
     # Storing server type
     $server_type = $params['type'];
     # Determine port to use
     $port = $params['type'] == "pop3" ? $params['secure'] ? 995 : 110 : ($params['secure'] ? 993 : 143);
     # Form server string
     $server = "{" . $params['server'] . ":{$port}/" . $params['type'];
     $server .= $params['secure'] ? "/ssl" : "";
     $server .= "}";
     # Attempt connection
     $this->conn = @imap_open($server . $params['mailbox'], $params['username'], $params['password']);
     # If failure also try with "notls" and "novalidate-cert" option
     if (!$this->conn) {
         $server = str_replace("}", "/notls}", $server);
         $this->conn = @imap_open($server . $params['mailbox'], $params['username'], $params['password']);
     }
     if (!$this->conn) {
         $server = str_replace("/notls}", "/novalidate-cert}", $server);
         $this->conn = @imap_open($server . $params['mailbox'], $params['username'], $params['password']);
     }
     # Connection made
     if ($this->conn) {
         # Keep track of server string
         $this->server = $server;
         # Retrieve number of messages in mailbox
         $this->num_msgs = imap_num_msg($this->conn);
         return true;
     } else {
         # If connection not made then log error
         return false;
     }
 }
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:38,代码来源:mail.class.php


示例6: __construct

	/**
	 * Opens up imap connection to the specified url
	 * @param $url String - mail server url
	 * @param $username String  - user name of the mail box
	 * @param $password String  - pass word of the mail box
	 * @param $baseUrl Optional - url of the mailserver excluding folder name.
	 *	This is used to fetch the folders of the mail box
	 */
	function __construct($url, $username, $password, $baseUrl=false) {
		$boxUrl = $this->convertCharacterEncoding(html_entity_decode($url),'UTF7-IMAP','UTF-8'); //handle both utf8 characters and html entities
		$this->mBoxUrl = $boxUrl;
		$this->mBoxBaseUrl = $baseUrl; // Used for folder List
		$this->mBox = @imap_open($boxUrl, $username, $password);
		$this->isError();
	}
开发者ID:nvh3010,项目名称:quancrm,代码行数:15,代码来源:Connector.php


示例7: openImap

 /**
  * @return resource
  */
 protected function openImap($server = null, $port = null, $protocol = null, $username = null, $password = null, $inbox = null)
 {
     if (!$server) {
         $server = $this->container->getParameter('ephp_imap.server');
     }
     if (!$port) {
         $port = $this->container->getParameter('ephp_imap.port');
     }
     if (!$protocol) {
         $protocol = $this->container->getParameter('ephp_imap.protocol');
     }
     if (!$username) {
         $username = $this->container->getParameter('ephp_imap.username');
     }
     if (!$password) {
         $password = $this->container->getParameter('ephp_imap.password');
     }
     $connection = '{' . $server . ':' . $port . '/' . $protocol . '}' . $inbox;
     try {
         $this->inbox = imap_open($connection, $username, $password);
         return $this->inbox;
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:ephp,项目名称:imap,代码行数:28,代码来源:ImapController.php


示例8: open

 function open($hostname, $username, $password)
 {
     $this->con = imap_open($hostname, $username, $password);
     if (!$this->con) {
         throw new \Exception("Unable to open connection to: " . $hostname . ' error: ' . imap_last_error());
     }
 }
开发者ID:splitice,项目名称:radical-mail,代码行数:7,代码来源:IMAP.php


示例9: 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;
}
开发者ID:remap,项目名称:ndn-status,代码行数:35,代码来源:imap.inc.php


示例10: connect

 function connect()
 {
     $this->stream = imap_open($this->mailbox, $this->username, $this->password);
     if ($this->stream === false) {
         trigger_error(sprintf("Invalid IMAP stream (Mailbox: %s / Username: %s)", $this->mailbox, $this->username), E_USER_WARNING);
     }
 }
开发者ID:optimumweb,项目名称:php-email-reader-parser,代码行数:7,代码来源:email_reader.php


示例11: Logon

 function Logon($username, $domain, $password)
 {
     $this->_wasteID = false;
     $this->_sentID = false;
     $this->_username = $username;
     $this->_domain = $domain;
     $this->_password = $password;
     if (!$this->getLdapAccount()) {
         return false;
     }
     $this->_server = "{" . $this->_KolabHomeServer . ":" . KOLAB_IMAP_PORT . "/imap" . KOLAB_IMAP_OPTIONS . "}";
     $this->Log("Connecting to " . $this->_server);
     if (!function_exists("imap_open")) {
         debugLog("ERROR BackendIMAP : PHP-IMAP module not installed!!!!!");
         $this->Log("module PHP imap not installed ");
     }
     // open the IMAP-mailbox
     $this->_mbox = @imap_open($this->_server, $username, $password, OP_HALFOPEN);
     $this->_mboxFolder = "";
     if ($this->_mbox) {
         debugLog("KolabBackend Version : " . KOLABBACKEND_VERSION);
         debugLog("KolabActiveSyndData Version : " . KOLABACTIVESYNCDATA_VERSION);
         $this->Log("KolabBackend Version : " . KOLABBACKEND_VERSION);
         $this->Log("KolabActiveSyndData Version : " . KOLABACTIVESYNCDATA_VERSION);
         $this->Log("IMAP connection opened sucessfully user : " . $username);
         // set serverdelimiter
         $this->_serverdelimiter = $this->getServerDelimiter();
         return true;
     } else {
         $this->Log("IMAP can't connect: " . imap_last_error() . "  user : " . $this->_user . " Mobile ID:" . $this->_devid);
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:z-push-svn,代码行数:33,代码来源:kolab.php


示例12: fetch

 public function fetch(MailCriteria $criteria, $callback)
 {
     $mailbox = @imap_open('{' . $this->host . ':' . $this->port . '}INBOX', $this->username, $this->password);
     if (!$mailbox) {
         throw new ImapException("Cannot connect to imap server: {$this->host}:{$this->port}'");
     }
     $this->checkProcessedFolder($mailbox);
     $emails = $this->fetchEmails($mailbox, $criteria);
     if ($emails) {
         foreach ($emails as $emailIndex) {
             $overview = imap_fetch_overview($mailbox, $emailIndex, 0);
             $message = imap_body($mailbox, $emailIndex);
             $email = new Email($overview, $message);
             $processed = $callback($email);
             if ($processed) {
                 $res = imap_mail_move($mailbox, $emailIndex, $this->processedFolder);
                 if (!$res) {
                     throw new \Exception("Unexpected error: Cannot move email to ");
                     break;
                 }
             }
         }
     }
     @imap_close($mailbox);
 }
开发者ID:martinstrycek,项目名称:imap-mail-downloader,代码行数:25,代码来源:Downloader.php


示例13: connect

 /**
  * Opens a connection to the server
  * @return boolean
  */
 function connect($server, $port, $login, $password)
 {
     $option = "/service=" . $this->_protocol;
     if ($this->_ssl) {
         $option .= "/ssl";
     }
     if ($this->_tls_on) {
         $option .= "/tls";
     } else {
         $option .= "/notls";
     }
     if ($this->_self_cert) {
         $option .= "/novalidate-cert";
     }
     if (preg_match("/google|gmail/i", $server)) {
         //Fix from Jim Hodgson http://www.jimhodgson.com/2006/07/19/postie/
         $this->_server_string = "{" . $server . ":" . $port . $option . "}INBOX";
     } else {
         $this->_server_string = "{" . $server . ":" . $port . $option . "}";
     }
     $this->_connection = imap_open($this->_server_string, $login, $password);
     if ($this->_connection) {
         $this->_connected = true;
     } else {
         LogInfo("imap_open failed: " . imap_last_error());
     }
     return $this->_connected;
 }
开发者ID:rogerhub,项目名称:postie,代码行数:32,代码来源:postieIMAP.php


示例14: getInbox

 private function getInbox($user_id)
 {
     if (!$this->inbox) {
         $this->inbox = imap_open($this->hostname, 'u' . $user_id . '@' . $this->domain, $user_id) or die('Cannot connect to Notify system');
     }
     return $this->inbox;
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:7,代码来源:EmailBasedNotify.php


示例15: Auth

 /**
  * Authenticate user/password
  *
  * @access  public
  * @param   string  $user       User's name or email
  * @param   string  $password   User's password
  * @return  mixed   Array of user's information otherwise Jaws_Error
  */
 function Auth($user, $password)
 {
     if (!function_exists('imap_open')) {
         return Jaws_Error::raiseError('Undefined function imap_open()', __FUNCTION__);
     }
     $mbox = @imap_open('{' . $this->_Server . ':' . $this->_Port . ($this->_SSL ? '/imap/ssl' : '') . '}INBOX', $user, $password);
     if ($mbox) {
         @imap_close($mbox);
         $result = array();
         $result['id'] = strtolower('imap:' . $user);
         $result['internal'] = false;
         $result['username'] = $user;
         $result['superadmin'] = false;
         $result['internal'] = false;
         $result['groups'] = array();
         $result['nickname'] = $user;
         $result['concurrents'] = 0;
         $result['email'] = '';
         $result['url'] = '';
         $result['avatar'] = 'gadgets/Users/Resources/images/photo48px.png';
         $result['language'] = '';
         $result['theme'] = '';
         $result['editor'] = '';
         $result['timezone'] = null;
         return $result;
     }
     return Jaws_Error::raiseError(_t('GLOBAL_ERROR_LOGIN_WRONG'), __FUNCTION__);
 }
开发者ID:juniortux,项目名称:jaws,代码行数:36,代码来源:IMAP.php


示例16: index

 public function index()
 {
     $this->template = "";
     $this->auto_render = FALSE;
     // First is IMAP PHP Library Installed?
     $modules = new Modulecheck();
     if ($modules->isLoaded('imap')) {
         // 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" : "";
         $service = "{" . Kohana::config('settings.email_host') . ":" . Kohana::config('settings.email_port') . "/" . Kohana::config('settings.email_servertype') . $notls . $ssl . $novalidate . "}";
         // Connected!
         if (@imap_open($service, Kohana::config('settings.email_username'), Kohana::config('settings.email_password'), 0, 1)) {
             echo json_encode(array("status" => "success", "message" => Kohana::lang('ui_main.success')));
         } else {
             echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_main.error') . " - " . imap_last_error()));
         }
     } else {
         echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_main.error') . " - " . Kohana::lang('ui_admin.error_imap')));
     }
 }
开发者ID:kjgarza,项目名称:ushahidi,代码行数:25,代码来源:test_email.php


示例17: initImapStream

	protected function initImapStream() {
		$imapStream = @imap_open($this->imapPath, $this->imapLogin, $this->imapPassword, $this->imapOptions, $this->imapRetriesNum, $this->imapParams);
		if(!$imapStream) {
			throw new Exception('Connection error: ' . imap_last_error());
		}
		return $imapStream;
	}
开发者ID:hoanghd,项目名称:tools,代码行数:7,代码来源:Mailbox.php


示例18: connect

 public function connect()
 {
     $this->stream = imap_open('{' . $this->hostname . $this->port . '/' . $this->driver . $this->ssl . $this->novalidate . '}INBOX', $this->username, $this->password) or die('Cannot connect to Server: ' . imap_last_error());
     if ($this->stream) {
         $this->isConnect = true;
     }
 }
开发者ID:nahidz,项目名称:imapx,代码行数:7,代码来源:Imapx.php


示例19: imap_connection

 /**
  * Create or return a connection to an imap server.
  * 
  * @access public
  * @static
  * @param mixed $id
  * @return void
  */
 public static function imap_connection($id)
 {
     if (!isset(static::$_imap_connections[$id])) {
         static::$_imap_connections[$id] = imap_open("{imap.1and1.co.uk:143/imap}INBOX", "[email protected]", "arBgjGjkS2010");
     }
     return static::$_imap_connections[$id];
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:15,代码来源:messages.php


示例20: handleJSON_getContent

 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     // Leer credenciales a partir del usuario y el perfil asociado
     global $arrConf;
     $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
     $pACL = new paloACL($dbAcl);
     $userId = $pACL->getIdUser($_SESSION['elastix_user']);
     $mailCred = $this->leerPropiedadesWebmail($dbAcl, $userId);
     if (count($mailCred) <= 0) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr("You don't have a webmail account");
     } elseif (!$this->_checkEmailPassword("{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '')) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = "{$mailCred['login']}@{$mailCred['domain']} " . _tr("does not exist locally or password is incorrect");
     } else {
         $imap = @imap_open("{localhost:143/notls}", "{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '');
         if (!$imap) {
             $respuesta['status'] = 'error';
             $respuesta['message'] = _tr('Imap: Connection error');
         } else {
             $this->leerInformacionImap($smarty, $module_name, $imap, $respuesta);
             imap_close($imap);
         }
     }
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
开发者ID:hardikk,项目名称:HNH,代码行数:29,代码来源:index.php



注:本文中的imap_open函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imap_ping函数代码示例发布时间:2022-05-15
下一篇:
PHP imap_num_msg函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap