本文整理汇总了PHP中imap_last_error函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_last_error函数的具体用法?PHP imap_last_error怎么用?PHP imap_last_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_last_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getdata
function getdata($host, $login, $password, $savedirpath)
{
$mbox = imap_open($host, $login, $password) or die("can't connect: " . imap_last_error());
$message = array();
$message["attachment"]["type"][0] = "text";
$message["attachment"]["type"][1] = "multipart";
$message["attachment"]["type"][2] = "message";
$message["attachment"]["type"][3] = "application";
$message["attachment"]["type"][4] = "audio";
$message["attachment"]["type"][5] = "image";
$message["attachment"]["type"][6] = "video";
$message["attachment"]["type"][7] = "other";
$buzon_destino = "cfdi";
echo imap_createmailbox($mbox, imap_utf7_encode("{$buzon_destino}"));
echo imap_num_msg($mbox);
for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++) {
$structure = imap_fetchstructure($mbox, $jk);
$parts = $structure->parts;
$fpos = 2;
for ($i = 1; $i < count($parts); $i++) {
$message["pid"][$i] = $i;
$part = $parts[$i];
if (strtolower($part->disposition) == "attachment") {
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
$message["subtype"][$i] = strtolower($part->subtype);
$ext = $part->subtype;
$params = $part->dparameters;
$filename = $part->dparameters[0]->value;
if (!($ext == 'xml' or $ext == 'XML' or $ext == 'PDF' or $ext == 'pdf')) {
continue;
}
$mege = "";
$data = "";
$mege = imap_fetchbody($mbox, $jk, $fpos);
$data = $this->getdecodevalue($mege, $part->type);
$fp = fopen($filename, 'w');
fputs($fp, $data);
fclose($fp);
$fpos += 1;
/* Se mueve el archiv descargado al directorio de recibidos */
// rename($filename, $savedirpath.$filename);
// printf("\nSe movio el archivo $filename");
}
}
$result = imap_fetch_overview($mbox, $jk);
echo $result[0]->from;
// imap_mail_move($mbox, $jk, $buzon_destino);
//imap_delete tags a message for deletion
// imap_delete($mbox,$jk);
}
// imap_expunge deletes all tagged messages
// imap_expunge($mbox);
imap_close($mbox);
}
示例2: fetchStructure
public function fetchStructure()
{
$structure = imap_fetchstructure($this->stream, $this->number);
if (FALSE === $structure) {
throw new Exception('FetchStructure failed: ' . imap_last_error());
}
return $structure;
}
示例3: 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;
}
}
示例4: 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;
}
示例5: authenticate_imap
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;
}
}
}
示例6: getMail
/**
* 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());
}
}
示例7: moveMailToFolder
/**
* @param $mail_id
* @param string $folder
*/
public function moveMailToFolder($mail_id, $folder = 'INBOX/Junk')
{
$imapresult = imap_mail_move($this->getImapStream(), $mail_id, $folder, CP_UID);
if (!$imapresult) {
echo imap_last_error();
}
}
示例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());
}
}
示例9: 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;
}
示例10: connect
protected function connect()
{
$this->mbox = @$this->imap_open($this->imapPath, $this->login, $this->password);
if (!$this->mbox) {
throw new ImapMailboxException('Connection error: ' . imap_last_error());
}
}
示例11: connect
public function connect()
{
if (empty($this->_connectionString)) {
$this->_connectionType = $this->_config['type'];
switch ($this->_config['type']) {
case 'imap':
$this->_connectionString = sprintf('{%s:%s%s%s}%s', $this->_config['server'], $this->_config['port'], '/' . $this->_config['type'], @$this->_config['ssl'] ? '/ssl' : '', !empty($this->_config['mailbox']) ? $this->_config['mailbox'] : '');
break;
case 'pop3':
$this->_connectionString = sprintf('{%s:%s/pop3%s}%s', $this->_config['server'], $this->_config['port'], @$this->_config['ssl'] ? '/ssl' : '', !empty($this->_config['mailbox']) ? $this->_config['mailbox'] : '');
break;
}
}
try {
$this->thread = null;
$retries = 0;
while ($retries++ < $this->_config['retry'] && !$this->thread) {
$this->Stream = imap_open($this->_connectionString, $this->_config['username'], $this->_config['password']);
$this->thread = @imap_thread($this->Stream);
}
if (!$this->thread) {
throw new \Exception('Unable to get imap_thread');
}
if (!$this->Stream) {
throw new \Exception('Connection error: ' . imap_last_error());
}
} catch (Exception $e) {
debug($e->getMessage);
}
return $this->_isConnected = true;
}
示例12: 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')));
}
}
示例13: getEmails
/**
* @return array
* @throws Exception
*/
public function getEmails()
{
$emails = imap_search($this->imap, 'ALL', SE_UID);
if ($emails === false) {
throw new Exception('Cannot get emails: ' . imap_last_error());
}
return $emails;
}
示例14: moveMail
public function moveMail($mailId)
{
$imapresult = imap_mail_move($this->getImapStream(), $mailId, 'INBOX.Archive') && $this->expungeDeletedMails();
if ($imapresult == false) {
error_log(imap_last_error());
}
return $imapresult;
}
示例15: initImapStream
protected function initImapStream()
{
$imapStream = @imap_open($this->imapPath, $this->login, $this->password);
if (!$imapStream) {
throw new ImapMailboxException('Connection error: ' . imap_last_error());
}
return $imapStream;
}