コード例 #1
4
 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 [];
     }
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
ファイル: mail.class.php プロジェクト: laiello/pivotx-sqlite
 /**
  * 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;
     }
 }
コード例 #5
0
 /**
  * Open mail from Imap and parse structure
  * @license   http://www.gnu.org/copyleft/gpl.html GPL
  * @author    Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
  * @return string  menssagem
  */
 public function setStructureFromMail($folder, $msgNumber)
 {
     $this->folder = mb_convert_encoding($folder, 'UTF7-IMAP', mb_detect_encoding($folder . 'x', 'UTF-8, ISO-8859-1'));
     $this->msgNumber = $msgNumber;
     $this->username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
     $this->password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
     $this->imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
     $this->imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
     $this->imap_delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'];
     $this->imap_sentfolder = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] : str_replace("*", "", $this->functions->getLang("Sent"));
     $this->has_cid = false;
     if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') {
         $this->imap_options = '/tls/novalidate-cert';
     } else {
         $this->imap_options = '/notls/novalidate-cert';
     }
     $this->mbox = @imap_open("{" . $this->imap_server . ":" . $this->imap_port . $this->imap_options . "}" . $this->folder, $this->username, $this->password) or die('Error');
     $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $this->msgNumber), 80, 255);
     $this->messageId = $header->message_id;
     $rawMessageData = $this->_getRaw();
     $decoder = new Mail_mimeDecode($rawMessageData);
     $this->structure = $decoder->decode($this->decodeConf);
     //TODO: Descartar código após atualização do módulo de segurança da SERPRO
     if ($this->isSignedMenssage()) {
         $this->convertSignedMenssage($rawMessageData);
     }
     //////////////////////////////////////////////////////
     /*
      * Clean memory and close imap connection
      */
     $rawMessageData = null;
     $decoder = null;
     @imap_close($this->mbox);
     //-----------------------------------------//
 }
コード例 #6
0
ファイル: Connector.php プロジェクト: nvh3010/quancrm
	/**
	 * 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();
	}
コード例 #7
0
ファイル: ImapController.php プロジェクト: ephp/imap
 /**
  * @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;
     }
 }
コード例 #8
0
ファイル: imap.php プロジェクト: kosli/apps
 /**
  * Check if the password is correct without logging in the user
  *
  * @param string $uid      The username
  * @param string $password The password
  *
  * @return true/false
  */
 public function checkPassword($uid, $password)
 {
     if (!function_exists('imap_open')) {
         OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR);
         return false;
     }
     // Check if we only want logins from ONE domain and strip the domain part from UID
     if ($this->domain != '') {
         $pieces = explode('@', $uid);
         if (count($pieces) == 1) {
             $username = $uid . "@" . $this->domain;
         } elseif (count($pieces) == 2 and $pieces[1] == $this->domain) {
             $username = $uid;
             $uid = $pieces[0];
         } else {
             return false;
         }
     } else {
         $username = $uid;
     }
     $mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1);
     imap_errors();
     imap_alerts();
     if ($mbox !== FALSE) {
         imap_close($mbox);
         $uid = mb_strtolower($uid);
         $this->storeUser($uid);
         return $uid;
     } else {
         return false;
     }
 }
コード例 #9
0
ファイル: IMAP.php プロジェクト: splitice/radical-mail
 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());
     }
 }
コード例 #10
0
ファイル: imap.inc.php プロジェクト: remap/ndn-status
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;
}
コード例 #11
0
 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);
     }
 }
コード例 #12
0
ファイル: kolab.php プロジェクト: BackupTheBerlios/z-push-svn
 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 : "******"IMAP can't connect: " . imap_last_error() . "  user : "******" Mobile ID:" . $this->_devid);
         return false;
     }
 }
コード例 #13
0
ファイル: IMAPParser.php プロジェクト: Bridgeborn/Swiftriver
 /**
  * Gets IMAP content
  *
  * @param string $imapHost
  * @param string $imapUser
  * @param string $imapPassword
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  *
  * @return $contentItems[]
  */
 private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel)
 {
     $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword);
     //Open up unseen messages
     $search = $channel->lastSuccess == null ? "UNSEEN" : "UNSEEN SINCE " . \date("Y-m-d", $channel->lastSuccess);
     $imapEmails = imap_search($imapResource, $search);
     $contentItems = array();
     if ($imapEmails) {
         //Put newest emails on top
         rsort($imapEmails);
         foreach ($imapEmails as $Email) {
             //Loop through each email and return the content
             $email_overview = imap_fetch_overview($imapResource, $Email, 0);
             if (strtotime(reset($email_overview)->date) < $channel->lastSuccess) {
                 continue;
             }
             $email_header_info = imap_header($imapResource, $Email);
             $email_message = imap_fetchbody($imapResource, $Email, 1);
             $source_name = \reset($email_overview)->from;
             $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name);
             $source->name = $source_name;
             $source->parent = $channel->id;
             $source->type = $channel->type;
             $source->subType = $channel->subType;
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message));
             //the message
             $item->link = null;
             $item->date = $email_header_info->udate;
             $contentItems[] = $item;
         }
     }
     imap_close($imapResource);
     return $contentItems;
 }
コード例 #14
0
ファイル: Imap.php プロジェクト: redspider/Ushahidi_Web
 /**
  * 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);
     }
 }
コード例 #15
0
 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;
 }
コード例 #16
0
ファイル: imap.php プロジェクト: BackupTheBerlios/z-push-svn
 function Logon($username, $domain, $password)
 {
     $this->_wasteID = false;
     $this->_sentID = false;
     $this->_server = "{" . IMAP_SERVER . ":" . IMAP_PORT . "/imap" . IMAP_OPTIONS . "}";
     if (!function_exists("imap_open")) {
         debugLog("ERROR BackendIMAP : PHP-IMAP module not installed!!!!!");
     }
     // open the IMAP-mailbox
     debugLog("Login starts here");
     $this->_mbox = @imap_open($this->_server, $username, $password, OP_HALFOPEN);
     debugLog("Login ended here");
     $this->_mboxFolder = "";
     if ($this->_mbox) {
         debugLog("IMAP connection opened sucessfully ");
         $this->_username = $username;
         $this->_domain = $domain;
         // set serverdelimiter
         $this->_serverdelimiter = $this->getServerDelimiter();
         $this->_loggedin = true;
         return true;
     } else {
         debugLog("IMAP can't connect: " . imap_last_error());
         return false;
     }
 }
コード例 #17
0
ファイル: test_email.php プロジェクト: kjgarza/ushahidi
 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')));
     }
 }
コード例 #18
0
ファイル: Mailbox.php プロジェクト: hoanghd/tools
	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;
	}
コード例 #19
0
ファイル: Imapx.php プロジェクト: nahidz/imapx
 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;
     }
 }
コード例 #20
0
ファイル: messages.php プロジェクト: ClixLtd/pccupload
 /**
  * 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", "*****@*****.**", "arBgjGjkS2010");
     }
     return static::$_imap_connections[$id];
 }
コード例 #21
0
ファイル: index.php プロジェクト: hardikk/HNH
 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);
 }
コード例 #22
0
ファイル: Emailcheck.php プロジェクト: bas2/classes
 public function __construct($email_addr, $host, $user, $pass, $exitifnoemails = 1)
 {
     error_reporting(0);
     if (!function_exists('imap_mail')) {
         echo '<p class="error">IMAP MAIL EXTENSION IS NOT AVAILABLE ON THIS SERVER!</p>';
         //exit;
         return false;
         # No need to exit entire page as other things might be there.
     }
     // End function.
     //$this->conn = imap_open ("{{$host}:143/notls}Inbox", $email_addr, $pass);
     $this->conn = imap_open("{{$host}:143/notls}Inbox", $user, $pass);
     //$this->conn = imap_open ("{{$host}:143}", $user, $pass);
     if (!$this->conn) {
         // Error occurred while try to connect:
         echo '<p class="error">Could not access mailbox</p>';
         //var_dump(imap_errors());
         imap_close($this->conn);
         exit;
     }
     // End if.
     // Get the number of mails on the server:
     $this->num_emails = imap_num_msg($this->conn);
     if ($this->num_emails == 0) {
         echo '<p class="error">No emails in mailbox</p>';
         imap_close($this->conn);
         if ($exitifnoemails) {
             exit;
         }
     }
     // End if.
 }
コード例 #23
0
function authenticate_imap($user, $pass)
{
    global $LOGIN_IMAP_CONNECTION;
    global $AUTH_ERR;
    if (hostname() == 'tauceti') {
        $server = '{localhost:143/imap/tls/novalidate-cert}';
    } elseif (hostname() == 'Daneel.dynamic.wondermill.com') {
        $server = '{localhost:143/imap/notls}';
    } else {
        $server = '{localhost:143/imap/tls/novalidate-cert}';
    }
    if ($c = imap_open($server, $user, $pass, OP_HALFOPEN)) {
        if (LOGIN_IMAP_KEEPCONNECTION) {
            $LOGIN_IMAP_CONNECTION =& $c;
        } else {
            //debug('Closing connection');
            imap_close($c);
        }
        return AUTH_SUCCESS;
    } else {
        if ($AUTH_ERR = imap_last_error()) {
            return AUTH_SERVFAIL;
        } else {
            return AUTH_DENY;
        }
    }
}
コード例 #24
0
ファイル: IMAP.php プロジェクト: juniortux/jaws
 /**
  * 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__);
 }
コード例 #25
0
ファイル: postieIMAP.php プロジェクト: rogerhub/postie
 /**
  * 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;
 }
コード例 #26
-1
 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);
 }
コード例 #27
-1
ファイル: emailblog.php プロジェクト: betsyzhang/chyrp
 /**
  * Gets the mail from the inbox
  * Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
  */
 function getMail()
 {
     $config = Config::current();
     if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
         $hostname = '{' . $config->emailblog_server . '}INBOX';
         # this isn't working well on localhost
         $username = $config->emailblog_address;
         $password = $config->emailblog_pass;
         $subjpass = $config->emailblog_subjpass;
         $inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
         $emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
         if ($emails) {
             rsort($emails);
             foreach ($emails as $email_number) {
                 $message = imap_body($inbox, $email_number);
                 $overview = imap_headerinfo($inbox, $email_number);
                 imap_delete($inbox, $email_number);
                 $title = htmlspecialchars($overview->Subject);
                 $title = preg_replace($subjpass, "", $title);
                 $clean = strtolower($title);
                 $body = htmlspecialchars($message);
                 # The subject of the email is used as the post title
                 # the content of the email is used as the body
                 # not sure about compatibility with images or audio feathers
                 Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
             }
         }
         # close the connection
         imap_close($inbox, CL_EXPUNGE);
         $config->set("emailblog_mail_checked", time());
     }
 }
コード例 #28
-1
ファイル: postieIMAP.php プロジェクト: robfelty/postie
 /**
  *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;
 }
コード例 #29
-1
ファイル: getSentMail.php プロジェクト: Legolas000/PaintBuddy
 public function getMailBox()
 {
     $mailboxes = array('label' => 'Gmail', 'enable' => true, 'mailbox' => '{imap.gmail.com:993/ssl}[Gmail]/Sent Mail', 'username' => '*****@*****.**', 'password' => '4N?@vwJn@resijt');
     $stream = imap_open($mailboxes['mailbox'], $mailboxes['username'], $mailboxes['password']);
     if (!$stream) {
         return 'err1';
         //return Redirect::back()->withInput()->withErrors('An error occured. Please try again.');
     }
     $emails = imap_search($stream, 'ALL');
     if (!$emails) {
         return 'err2';
     } else {
         rsort($emails);
     }
     $emailList = array();
     $count = 0;
     foreach ($emails as $item) {
         $overview = imap_fetch_overview($stream, $item, 0);
         $emailList[$count] = $overview;
         $emailList[$count]['agoTime'] = Carbon::createFromTimestampUTC(strtotime($overview[0]->date))->diffForHumans();
         $count++;
     }
     imap_close($stream);
     return $emailList;
 }
コード例 #30
-4
ファイル: auth.php プロジェクト: bitweaver/users
    function validate($user, $pass, $challenge, $response)
    {
        parent::validate($user, $pass, $challenge, $response);
        $mailbox = '{' . $this->mConfig['server'];
        if ($this->mConfig["ssl"]) {
            $mailbox .= "/ssl";
            if ($this->mConfig["sslvalidate"]) {
                $mailbox .= "/validate-cert";
            } else {
                $mailbox .= "/novalidate-cert";
            }
        }
        $mailbox .= ':' . $this->mConfig["port"] . '}INBOX';
        $imapauth = @imap_open($mailbox, $user, $pass);
        if (!$imapauth) {
            $this->mErrors['login'] = imap_errors();
            $ret = USER_NOT_FOUND;
        } else {
            $ret = USER_VALID;
            $this->mInfo["real_name"] = $user;
            if (empty($this->mConfig["email"])) {
                $this->mInfo["email"] = $user;
            } else {
                $info = array('login' => $user);
                $replace_func = create_function('$matches', '$info = ' . var_export($info, true) . ';
							$m = $matches[0];
							$m = substr($m,1,strlen($m)-2);
							if(empty($info[$m])) return "";
							return strtolower($info[$m]);');
                $this->mInfo["email"] = preg_replace_callback('/%.*?%/', $replace_func, $this->mConfig["email"]);
            }
            imap_close($imapauth);
        }
        return $ret;
    }