本文整理汇总了PHP中imap_header函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_header函数的具体用法?PHP imap_header怎么用?PHP imap_header使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_messages
/**
* Get messages according to a search criteria
*
* @param string search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default
* NB: Search criteria only affects IMAP mailboxes.
* @param string date format. Set to "Y-m-d H:i:s" by default
* @return mixed array containing messages
*/
public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s")
{
$msgs = imap_search($this->imap_stream, $search_criteria);
$no_of_msgs = $msgs ? count($msgs) : 0;
$messages = array();
for ($i = 0; $i < $no_of_msgs; $i++) {
// Get Message Unique ID in case mail box changes
// in the middle of this operation
$message_id = imap_uid($this->imap_stream, $msgs[$i]);
$header = imap_header($this->imap_stream, $message_id);
$date = date($date_format, $header->udate);
$from = $header->from;
$fromname = "";
$fromaddress = "";
$subject = "";
foreach ($from as $id => $object) {
if (isset($object->personal)) {
$fromname = $object->personal;
}
$fromaddress = $object->mailbox . "@" . $object->host;
if ($fromname == "") {
// In case from object doesn't have Name
$fromname = $fromaddress;
}
}
if (isset($header->subject)) {
$subject = $this->_mime_decode($header->subject);
}
$structure = imap_fetchstructure($this->imap_stream, $message_id);
$body = '';
if (!empty($structure->parts)) {
for ($j = 0, $k = count($structure->parts); $j < $k; $j++) {
$part = $structure->parts[$j];
if ($part->subtype == 'PLAIN') {
$body = imap_fetchbody($this->imap_stream, $message_id, $j + 1);
}
}
} else {
$body = imap_body($this->imap_stream, $message_id);
}
// Convert quoted-printable strings (RFC2045)
$body = imap_qprint($body);
array_push($messages, array('msg_no' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body));
// Mark Message As Read
imap_setflag_full($this->imap_stream, $message_id, "\\Seen");
}
return $messages;
}
示例2: get_messages
/**
* Get messages according to a search criteria
*
* @param string search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default
NB: Search criteria only affects IMAP mailboxes.
* @param string date format. Set to "Y-m-d H:i:s" by default
* @return mixed array containing messages
*/
public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s")
{
$msgs = imap_search($this->imap_stream, $search_criteria);
$no_of_msgs = $msgs ? count($msgs) : 0;
$messages = array();
for ($i = 0; $i < $no_of_msgs; $i++) {
$header = imap_header($this->imap_stream, $msgs[$i]);
$date = date($date_format, $header->udate);
$from = $this->_mime_decode($header->fromaddress);
$subject = $this->_mime_decode($header->subject);
$structure = imap_fetchstructure($this->imap_stream, $msgs[$i]);
if (!empty($structure->parts)) {
for ($j = 0, $k = count($structure->parts); $j < $k; $j++) {
$part = $structure->parts[$j];
if ($part->subtype == 'PLAIN') {
$body = imap_fetchbody($this->imap_stream, $msgs[$i], $j + 1);
}
}
} else {
$body = imap_body($this->imap_stream, $msgs[$i]);
}
// Convert quoted-printable strings (RFC2045)
$body = imap_qprint($body);
array_push($messages, array('msg_no' => $msgs[$i], 'date' => $date, 'from' => $from, 'subject' => $subject, 'body' => $body));
}
return $messages;
}
示例3: readMessage
public function readMessage($messageid)
{
$message = array();
$header = imap_header($this->mailbox, $messageid);
$structure = imap_fetchstructure($this->mailbox, $messageid);
$message['subject'] = $header->subject;
$message['fromaddress'] = $header->fromaddress;
$message['toaddress'] = $header->toaddress;
//$message['ccaddress'] = $header->ccaddress;
$message['date'] = $header->date;
$message['id'] = $messageid;
if ($this->check_type($structure)) {
$message['body'] = imap_fetchbody($this->mailbox, $messageid, "2");
## GET THE BODY OF MULTI-PART MESSAGE
if (!$message['body']) {
$message['body'] = '[NO TEXT ENTERED INTO THE MESSAGE]\\n\\n';
}
} else {
$message['body'] = imap_body($this->mailbox, $messageid);
if (!$message['body']) {
$message['body'] = '[NO TEXT ENTERED INTO THE MESSAGE]\\n\\n';
}
}
return $message;
}
示例4: messages
/**
* @param string $criteria
* @return $this
*/
public function messages($criteria)
{
$this->messages = array_map(function ($messageNumber) {
return array('id' => $messageNumber, 'header' => imap_header($this->mailbox, $messageNumber), 'struct' => imap_fetchstructure($this->mailbox, $messageNumber));
}, imap_search($this->mailbox, $criteria));
return $this;
}
示例5: pop3_body
function pop3_body()
{
$imap = imap_open("{pop.163.com:110/pop3/notls}", "rong360credit01", "rong36000");
$message_count = imap_num_msg($imap);
for ($i = 1; $i <= $message_count; ++$i) {
$header = imap_header($imap, $i);
$date = $header->date;
echo "************msg no: {$i} \n {$date} \n";
$structure = imap_fetchstructure($imap, $i);
// print_r($structure) ;
}
imap_close($imap);
}
示例6: retrieve_message
function retrieve_message($auth_user, $accountid, $messageid, $fullheaders)
{
$message = array();
if (!($auth_user && $messageid && $accountid)) {
return false;
}
$imap = open_mailbox($auth_user, $accountid);
if (!$imap) {
return false;
}
$header = imap_header($imap, $messageid);
if (!$header) {
return false;
}
$message['body'] = imap_body($imap, $messageid);
if (!$message['body']) {
$message['body'] = "[This message has no body]\n\n\n\n\n\n";
}
if ($fullheaders) {
$message['fullheaders'] = imap_fetchheader($imap, $messageid);
} else {
$message['fullheaders'] = '';
}
$message['subject'] = $header->subject;
$message['fromaddress'] = $header->fromaddress;
$message['toaddress'] = $header->toaddress;
$message['ccaddress'] = $header->ccaddress;
$message['date'] = $header->date;
// note we can get more detailed information by using from and to
// rather than fromaddress and toaddress, but these are easier
imap_close($imap);
return $message;
}
示例7: mp_header
function mp_header($mbox, $messageid)
{
$header = imap_header($mbox, $messageid);
$h = array();
if (isset($header->Msgno)) {
$h['Msgno'] = $header->Msgno;
}
if (isset($header->from[0])) {
$h['from'] = mp_decode($header->fromaddress);
}
if (isset($header->to[0])) {
$h['to'] = mp_decode($header->toaddress);
}
if (isset($header->cc[0])) {
$h['cc'] = mp_decode($header->ccaddress);
}
if (isset($header->subject)) {
$h['subject'] = mp_decode($header->subject);
}
if (isset($header->Date)) {
$h['Date'] = $header->Date;
}
if (isset($header->Size)) {
$h['Size'] = $header->Size;
}
$h['Deleted'] = $header->Deleted == 'D' ? 1 : 0;
return $h;
}
示例8: GetIMAPContent
/**
* 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;
}
示例9: getHeaders
function getHeaders($mid)
{
if (!$this->marubox) {
return false;
}
$mail_header = imap_header($this->marubox, $mid);
$sender = $mail_header->from[0];
// var_dump(strtolower($sender->mailbox));
// return $this->marubox;
$sender_replyto = $mail_header->reply_to[0];
$mail_details = array();
if (strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster') {
date_default_timezone_set('PRC');
$subject = imap_mime_header_decode($mail_header->subject);
$toaddress = imap_mime_header_decode($mail_header->toaddress);
$mail_details = array('from' => strtolower($sender->mailbox) . '@' . $sender->host, 'fromName' => "", 'fromName_charset' => "", 'toOth' => strtolower($sender_replyto->mailbox) . '@' . $sender_replyto->host, 'toNameOth' => "", 'subject' => $subject[0]->text, 'subject_charset' => $subject[0]->charset, 'mailDate' => date("Y-m-d H:i:s", $mail_header->udate), 'udate' => $mail_header->udate, 'to' => $toaddress[0]->text);
if (isset($sender->personal)) {
$sPersonal = imap_mime_header_decode($sender->personal);
$mail_details['fromName'] = $sPersonal[0]->text;
$mail_details['fromName_charset'] = $sPersonal[0]->charset;
}
if (isset($sender_replyto->personal)) {
$rePersonal = imap_mime_header_decode($sender_replyto->personal);
$mail_details['toNameOth'] = $rePersonal[0]->text;
}
}
return $mail_details;
}
示例10: getmsg
function getmsg($mid)
{
// the message may in $htmlmsg, $plainmsg, or both
$this->htmlmsg = "";
$this->plainmsg = "";
$this->charset = '';
$this->attachments = array();
// HEADER
$h = imap_header($this->mbox, $mid);
// add code here to get date, from, to, cc, subject...
// BODY
$s = imap_fetchstructure($this->mbox, $mid);
if (!isset($s->parts) || !$s->parts) {
$this->getpart($mid, $s, 0);
// no part-number, so pass 0
// multipart: iterate through each part
} else {
foreach ($s->parts as $partno0 => $p) {
$this->getpart($mid, $p, $partno0 + 1);
}
}
// データを返す
$result = array();
$result["header"] = $h;
$result["html"] = $this->htmlmsg;
$result["plain"] = $this->plainmsg;
$result["charset"] = $this->charset;
$result["attachments"] = $this->attachments;
return $result;
}
示例11: imap_read_mail
function imap_read_mail($mail_id)
{
$mail_header = imap_header($this->conn, $mail_id);
$mail_body = imap_body($this->conn, $mail_id);
foreach ($mail_header as $mail_head) {
$mail[] = $mail_head;
}
$mail['body'] = $mail_body;
return $mail;
}
示例12: getHeaders
function getHeaders($mid)
{
$mail_header = imap_header($this->marubox, $mid);
$sender = $mail_header->from[0];
$sender_replyto = $mail_header->reply_to[0];
if (strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster') {
$mail_details = array('from' => strtolower($sender->mailbox) . '@' . $sender->host, 'fromName' => $sender->personal, 'toOth' => strtolower($sender_replyto->mailbox) . '@' . $sender_replyto->host, 'toNameOth' => $sender_replyto->personal, 'subject' => $mail_header->subject, 'to' => strtolower($mail_header->toaddress));
}
return $mail_details;
}
示例13: get_info
function get_info($message_number) {
$info = array();
$header = @imap_header($this->connect, $message_number);
$info['from'] = @imap_rfc822_write_address($header->from[0]->mailbox, $header->from[0]->host, "");
$info['to'] = @$this->identifiant;
$info['subject'] = $this->formate_subject(@$header->subject);
$info['date'] = $this->formate_date(@$header->date);
$info['message_id'] = @$header->message_id;
return $info;
}
示例14: getHeaders
function getHeaders($mid)
{
if (!$this->marubox) {
return false;
}
$mail_header = imap_header($this->marubox, $mid);
if (strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster') {
$mail_details = $mail_header;
}
return $mail_details;
}
示例15: getHeaders
function getHeaders($mid)
{
$mail_header = imap_header($this->mailResource, $mid);
$sender = $mail_header->from[0];
$sender_replyto = $mail_header->reply_to[0];
$stat = strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster' ? FALSE : TRUE;
if (strpos($mail_header->subject, "delayed")) {
$stat = FALSE;
}
$mail_details = array('from' => strtolower($sender->mailbox) . '@' . $sender->host, 'fromName' => $sender->personal, 'toOth' => strtolower($sender_replyto->mailbox) . '@' . $sender_replyto->host, 'toNameOth' => $sender_replyto->personal, 'subject' => $mail_header->subject, 'to' => strtolower($mail_header->toaddress), 'bounce' => $stat, 'date' => $mail_header->date);
return $mail_details;
}