本文整理汇总了PHP中imap_append函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_append函数的具体用法?PHP imap_append怎么用?PHP imap_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_append函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store_email_into_folder
function store_email_into_folder($msg, $folder = 'SentFromDolibarr')
{
global $user, $db;
$mailboxconfig = new Usermailboxconfig($db);
$mailboxconfig->fetch_from_user($user->id);
$user->mailbox_imap_login = $mailboxconfig->mailbox_imap_login;
$user->mailbox_imap_password = $mailboxconfig->mailbox_imap_password;
$user->mailbox_imap_host = $mailboxconfig->mailbox_imap_host;
$user->mailbox_imap_port = $mailboxconfig->mailbox_imap_port;
$user->mailbox_imap_ssl = $mailboxconfig->mailbox_imap_ssl;
$user->mailbox_imap_ssl_novalidate_cert = $mailboxconfig->mailbox_imap_ssl_novalidate_cert;
$user->mailbox_imap_ref = $mailboxconfig->get_ref();
$user->mailbox_imap_connector_url = $mailboxconfig->get_connector_url();
$mbox = imap_open($user->mailbox_imap_connector_url . $folder, $user->mailbox_imap_login, $user->mailbox_imap_password);
$check = imap_check($mbox);
$before = $check->Nmsgs;
$result = imap_append($mbox, $user->mailbox_imap_connector_url . $folder, $msg);
$check = imap_check($mbox);
$after = $check->Nmsgs;
if ($result == FALSE) {
if (imap_createmailbox($mbox, imap_utf7_encode($user->mailbox_imap_ref . $folder))) {
$mbox = imap_open($user->mailbox_imap_connector_url . $folder, $user->mailbox_imap_login, $user->mailbox_imap_password);
$check = imap_check($mbox);
$before = $check->Nmsgs;
$result = imap_append($mbox, $user->mailbox_imap_connector_url . $folder, $msg);
$check = imap_check($mbox);
$after = $check->Nmsgs;
}
}
imap_close($mbox);
}
示例2: appendMessage
/**
* Appends a message to a mailbox
* @param string $mailbox The mailbox to append the message to
* @param zibo\library\mail\Message $message The message to append
* @return null
* @throws zibo\library\mail\exception\MailException when th message could not be appended to the mailbox
*/
public function appendMessage($mailbox, Message $message)
{
$parser = new MessageParser($message);
$message = 'Subject: ' . $parser->getSubject() . "\r\n";
$message .= implode("\r\n", $parser->getHeaders());
$message .= "\r\n\r\n" . $parser->getBody();
$connection = $this->getConnection($mailbox);
$stream = $connection->getStream();
$reference = $connection->getReference();
if (!imap_append($stream, $reference, $message)) {
throw new MailException('Could not append the message to ' . $mailbox . ': ' . imap_last_error());
}
}
示例3: addmail
/**
* @name: addmail
* Wenn die Mails nicht per imap geholt werden, fuege die Mail mit allen header-Daten aus $xarf als Mail ein.
*
* @param $xarf-report
* @return Boolean
*/
public function addmail($xarf)
{
$config = $this->config;
preg_match('/subject: (.*)/im', $xarf, $subject);
$this->subject = $subject[1];
$xarf = str_replace("\n", "\r\n", $xarf);
$check = imap_check($this->connection);
$add = imap_append($this->connection, '{' . $config['server'] . ':' . $config['port'] . '/' . $config['conntyp'] . '/' . $config['extras'] . '}' . $config['ordner'], stripslashes($xarf));
$check1 = imap_check($this->connection);
if ($check < $check1 && $add == 1) {
$return = 0;
} else {
$return = 1;
}
return $return;
}
示例4: copyToFolder
/**
* Save email to a folder (via IMAP)
*
* This function will open an IMAP stream using the email
* credentials previously specified, and will save the email
* to a specified folder. Parameter is the folder name (ie, Sent)
* if nothing was specified it will be saved in the inbox.
*
* @author David Tkachuk <http://davidrockin.com/>
*/
public function copyToFolder($folderPath = "SendByWebsite")
{
$message = $this->MIMEHeader . $this->MIMEBody;
//$path = "";//"INBOX" . (isset($folderPath) && !is_null($folderPath) ? ".".$folderPath : ""); // Location to save the email
$imapStream = imap_open("{imap.mail.hostpoint.ch:143/notls}SendByWebsite", $this->Username, $this->Password);
/* $arr = imap_getmailboxes($imapStream, "{imap.mail.hostpoint.ch:143}", "*");
Use this to find the Folder to save the sent email to
if (is_array($arr)) {
foreach ($arr as $key => $val) {
echo "($key) ";
echo imap_utf7_decode($val->name) . ",";
echo "'" . $val->delimiter . "',";
echo $val->attributes . "<br />\n";
}
} else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}
*/
if ($imapStream != false) {
imap_append($imapStream, "{imap.mail.hostpoint.ch:143/notls" . $folderPath . "}", $message);
imap_close($imapStream);
}
}
示例5: create_multipart_message
/**
* Create a multipart message with subparts
*
* @param resource $imap_stream
* @param string $mailbox
*/
function create_multipart_message($imap_stream, $mailbox)
{
global $users, $domain;
$envelope["from"] = "foo@anywhere.com";
$envelope["to"] = "{$users['0']}@{$domain}";
$envelope["subject"] = "Test msg 1";
$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";
$part2["type"] = TYPETEXT;
$part2["subtype"] = "plain";
$part2["description"] = "imap_mail_compose() function";
$part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx";
$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "Example";
$part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy";
$file_handle = fopen(__FILE__, 'r+');
$file_size = 1;
$part4["type"] = TYPEAPPLICATION;
$part4["encoding"] = ENCBASE64;
$part4["subtype"] = "octet-stream";
$part4["description"] = 'Test';
$part4['disposition.type'] = 'attachment';
$part4['disposition'] = array('filename' => 'Test');
$part4['type.parameters'] = array('name' => 'Test');
$part4["contents.data"] = base64_encode(fread($file_handle, 1));
$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;
$body[4] = $part4;
$msg = imap_mail_compose($envelope, $body);
if (imap_append($imap_stream, $mailbox, $msg) === false) {
echo imap_last_error() . "\n";
echo "TEST FAILED : could not append new message to mailbox '{$mailbox}'\n";
exit;
}
}
示例6: addMail
public function addMail($msg, $seen = true)
{
return imap_append($this->getImapStream(), $this->imapPath, $msg . "\r\n", $seen ? "\\Seen" : null);
}
示例7: copyToFolder
/**
* Save email to a folder (via IMAP)
*
* This function will open an IMAP stream using the email
* credentials previously specified, and will save the email
* to a specified folder. Parameter is the folder name (ie, Sent)
* if nothing was specified it will be saved in the inbox.
*
* @author David Tkachuk <http://davidrockin.com/>
*/
public function copyToFolder($folderPath = null)
{
$message = $this->MIMEHeader . $this->MIMEBody;
$path = "INBOX" . (isset($folderPath) && !is_null($folderPath) ? "." . $folderPath : "");
// Location to save the email
$imapStream = imap_open("{" . $this->Host . "}" . $path, $this->Username, $this->Password);
imap_append($imapStream, "{" . $this->Host . "}" . $path, $message);
imap_close($imapStream);
}
示例8: saveMailToImap
public function saveMailToImap($content, $folder = 'INBOX')
{
imap_append($this->imapStream, $this->getMailbox() . $folder, $content);
}
示例9: appendMessage
public function appendMessage($message, $box = 'IMAP.Sent', $flags = null, $messageId = null)
{
$mailbox = $this->imap->reopen($box);
$date = null;
if ($messageId) {
//var_dump($messageId);
$messageId = imap_uid($this->connection, $messageId);
//var_dump($messageId);
$headerinfo = imap_headerinfo($this->connection, $messageId);
$date = date('d-M-Y H:i:s O', $headerinfo->udate);
}
$result = imap_append($this->connection, $mailbox, $message, $flags);
$this->fullName = $this->imap->reopen($this->name);
return $result;
}
示例10: send
//.........这里部分代码省略.........
}
if (strpos($description, '$logo$')) {
$description = str_replace('$logo$', "<img src='cid:logo' />", $description);
$logo = true;
}
foreach ($emails as $email) {
$mailer->Body = '';
if ($parentModule) {
$mailer->Body = $this->getTrackImageDetails($id, $this->isEmailTrackEnabled());
}
$mailer->Body .= $description;
$mailer->Signature = str_replace(array('\\r\\n', '\\n'), '<br>', $currentUserModel->get('signature'));
if ($mailer->Signature != '') {
$mailer->Body .= '<br><br>' . decode_html($mailer->Signature);
}
$mailer->Subject = $subject;
$mailer->AddAddress($email);
//Adding attachments to mail
if (is_array($attachments)) {
foreach ($attachments as $attachment) {
$fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
if (is_file($fileNameWithPath)) {
$mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
}
}
}
if ($logo) {
//While sending email template and which has '$logo$' then it should replace with company logo
$mailer->AddEmbeddedImage(dirname(__FILE__) . '/../../../layouts/vlayout/skins/images/logo_mail.jpg', 'logo', 'logo.jpg', 'base64', 'image/jpg');
}
$ccs = array_filter(explode(',', $this->get('ccmail')));
$bccs = array_filter(explode(',', $this->get('bccmail')));
if (!empty($ccs)) {
// SalesPlatform.ru begin
foreach ($ccs as $cc) {
$mailer->AddCC($idn->encode($cc));
}
//$mailer->AddCC($cc);
// SalesPlatform.ru end
}
if (!empty($bccs)) {
// SalesPlatform.ru begin
foreach ($bccs as $bcc) {
$mailer->AddBCC($idn->encode($bcc));
}
//$mailer->AddBCC($bcc);
// SalesPlatform.ru end
}
}
// SalesPlatform.ru begin
$idn = new idna_convert();
$query = "select * from vtiger_systems where server_type=?";
$params = array('email');
//SalesPlatform begin fix bug
$adb = PearDatabase::getInstance();
//SalesPaltform.ru end
$result = $adb->pquery($query, $params);
$server_username = $adb->query_result($result, 0, 'server_username');
$from_name_db = $adb->query_result($result, 0, 'from_name');
$server_port = $adb->query_result($result, 0, 'server_port');
$server_tls = $adb->query_result($result, 0, 'server_tls');
if ($server_username != '') {
$server_username = $idn->encode($server_username);
$mailer->Username = $server_username;
}
if (isset($from_name_db) && $from_name_db != '') {
$mailer->FromName = decode_html($from_name_db);
}
$from_email = $adb->query_result($result, 0, 'from_email_field');
if ($from_email != '') {
$mailer->From = $idn->encode($from_email);
}
if (!empty($server_port) && $server_port != 0) {
$mailer->Port = $server_port;
}
if (!empty($server_tls) && $server_tls != 'no') {
$mailer->SMTPSecure = $server_tls;
}
$use_sendmail = $adb->query_result($result, 0, 'use_sendmail');
if ($use_sendmail == "on") {
$mailer->IsSendmail();
} else {
$mailer->IsSMTP();
}
// SalesPlatform.ru end
$status = $mailer->Send(true);
if (!$status) {
$status = $mailer->getError();
} else {
$mailString = $mailer->getMailString();
$mailBoxModel = MailManager_Mailbox_Model::activeInstance();
$folderName = $mailBoxModel->folder();
if (!empty($folderName) && !empty($mailString)) {
$connector = MailManager_Connector_Connector::connectorWithModel($mailBoxModel, '');
imap_append($connector->mBox, $connector->mBoxUrl . $folderName, $mailString, "\\Seen");
}
}
}
return $status;
}
示例11: imap_open
//send the message, check for errors
$result = $mail->send();
if (!$result) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
$host = '{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail';
$user = 'noreply@vitriviera.com';
$password = 'GDGpass123';
$mbox = imap_open($host, $user, $password);
$count = 0;
if (!$mbox) {
echo "IMAP Error";
} else {
$dmy = date("d-M-Y H:i:s");
$msg = "From: {$event_mail}\r\n" . "To: {$to}\r\n" . "Date: {$dmy}\r\n" . "Subject: {$subject}\r\n" . "Message: {$message}\r\n";
if (imap_append($mbox, $host, $msg)) {
echo "<h3><center>Message sent!</h3></center>";
} else {
echo "<h3><center>Message not sent!</h3></center>";
}
imap_close($mbox);
}
}
} else {
echo "Connection Failed";
}
mysqli_close($mysqli);
} else {
if (isset($_SESSION["ec_name"]) && !isset($_REQUEST["id"])) {
header("Location:ec_home.php");
} else {
示例12: create
//.........这里部分代码省略.........
* Stop searching in all folders
*/
return $data;
}
}
}
}
return array();
case 'message':
require_once ROOTPATH . '/library/uuid/class.uuid.php';
$GLOBALS['phpgw_info']['flags'] = array('noheader' => true, 'nonavbar' => true, 'currentapp' => 'expressoMail', 'enable_nextmatchs_class' => True);
$return = array();
require_once dirname(__FILE__) . '/../../services/class.servicelocator.php';
$mailService = ServiceLocator::getService('mail');
$msg_uid = $data['msg_id'];
$body = $data['body'];
$body = str_replace("<", "&yzwkx;", $body);
//Alterar as Entities padrão das tags < > para compatibilizar com o Expresso
$body = str_replace(">", "&xzwky;", $body);
$body = str_replace("%nbsp;", " ", $body);
$body = html_entity_decode($body, ENT_QUOTES, 'ISO-8859-1');
$body = str_replace("&yzwkx;", "<", $body);
$body = str_replace("&xzwky;", ">", $body);
$folder = mb_convert_encoding($data['folder'], "UTF7-IMAP", "ISO-8859-1, UTF-8");
$folder = @preg_replace('/INBOX[\\/.]/i', "INBOX" . $this->imap_delimiter, $folder);
/**
* Gera e preenche o field Message-Id do header
*/
$mailService->addHeaderField('Message-Id', UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING) . '@Draft');
$mailService->addHeaderField('Reply-To', mb_convert_encoding($data['input_reply_to'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
$mailService->addHeaderField('Date', date("d-M-Y H:i:s"));
$mailService->addTo(mb_convert_encoding($data['input_to'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
$mailService->addCc(mb_convert_encoding($data['input_cc'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
$mailService->addBcc(mb_convert_encoding($data['input_cco'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
$mailService->setSubject(mb_convert_encoding($data['input_subject'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
if (isset($data['input_important_message'])) {
$mailService->addHeaderField('Importance', 'High');
}
if (isset($data['input_return_receipt'])) {
$mailService->addHeaderField('Disposition-Notification-To', Config::me('mail'));
}
$this->rfc2397ToEmbeddedAttachment($mailService, $body);
$isHTML = isset($data['type']) && $data['type'] == 'html' ? true : false;
if (!$body) {
$body = ' ';
}
$mbox_stream = $this->open_mbox($folder);
$attachment = json_decode($data['attachments'], TRUE);
if (!empty($attachment)) {
foreach ($attachment as &$value) {
if ((int) $value > 0) {
$att = Controller::read(array('id' => $value, 'concept' => 'mailAttachment'));
if ($att['disposition'] == 'embedded' && $isHTML) {
$body = str_replace('"../prototype/getArchive.php?mailAttachment=' . $att['id'] . '"', '"' . mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1') . '"', $body);
$mailService->addStringImage(base64_decode($att['source']), $att['type'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
} else {
$mailService->addStringAttachment(base64_decode($att['source']), mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'), $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] : 'attachment');
}
unset($att);
} else {
$value = json_decode($value, true);
switch ($value['type']) {
case 'imapPart':
$att = $this->getForwardingAttachment($value['folder'], $value['uid'], $value['part']);
if (strstr($body, 'src="./inc/get_archive.php?msgFolder=' . $value['folder'] . '&msgNumber=' . $value['uid'] . '&indexPart=' . $value['part'] . '"') !== false) {
$body = str_ireplace('src="./inc/get_archive.php?msgFolder=' . $value['folder'] . '&msgNumber=' . $value['uid'] . '&indexPart=' . $value['part'] . '"', 'src="' . $att['name'] . '"', $body);
$mailService->addStringImage($att['source'], $att['type'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
} else {
$mailService->addStringAttachment($att['source'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'), $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] : 'attachment');
}
unset($att);
break;
case 'imapMSG':
$mbox_stream = $this->open_mbox($value['folder']);
$rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']);
$mailService->addStringAttachment($rawmsg, mb_convert_encoding(base64_decode($value['name']), 'ISO-8859-1', 'UTF-8,ISO-8859-1'), 'message/rfc822', '7bit', 'attachment');
unset($rawmsg);
break;
default:
break;
}
}
}
}
if ($isHTML) {
$mailService->setBodyHtml($body);
} else {
$mailService->setBodyText(mb_convert_encoding($body, 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
}
if (imap_append($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, $mailService->getMessage(), "\\Seen \\Draft")) {
$status = imap_status($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, SA_UIDNEXT);
$return['id'] = $status->uidnext - 1;
if ($data['uidsSave']) {
$this->delete_msgs(array('folder' => $folder, 'msgs_number' => $data['uidsSave']));
}
Logger::info('expressomail', 'SAVEMSG', 'ID: ' . $return['id'] . ' # ' . 'Subject:' . $data['input_subject']);
}
return $return;
}
}
示例13: importMail
/**
* This method provides the functionality to import MIME messages into the server
* using the {@link imap_append} method.
*
* @param string $dest_mb
* The destination mailbox where the messages will be imported to.
* @param array $messages
* An array of MIME messages to import.
*
* @return BOOL
* @access public
* @see imap_append
* @tutorial http://www.smilingsouls.net/Mail_IMAP?content=Mail_IMAP_ManageMB/importMail
*/
function importMail($dest_mb, $messages)
{
if (is_array($messages)) {
$opt = isset($this->option['append']) ? $this->option['append'] : NULL;
foreach ($messages as $msg) {
if (!@imap_append($this->mailbox, $this->mailboxInfo['host'] . $dest_mb, $msg, $opt)) {
$this->error->push(Mail_IMAPv2_ERROR, 'error', NULL, 'Unable to import message, imap_append failed!');
$ret = FALSE;
}
}
if (!isset($ret)) {
$ret = TRUE;
}
} else {
$this->error->push(Mail_IMAPv2_ERROR_ARGUMENT_REQUIRES_ARRAY, 'error', array('arg' => '$messages'));
$ret = FALSE;
}
return $ret;
}
示例14: sendToServerThroughIMAP
function sendToServerThroughIMAP($server, $with_ssl, $transport, $ssl_port, $box, $from, $password, $content)
{
$password = self::ENCRYPT_DECRYPT($password);
$ssl = $with_ssl == '1' || $transport == 'ssl' ? '/ssl' : '';
$tls = $transport == 'tls' ? '/tls' : '';
$no_valid_cert = $ssl == '' && $tls == '' ? '/novalidate-cert' : '';
$port = $with_ssl == '1' ? ':' . $ssl_port : '';
$mail_box = isset($box) ? $box : 'INBOX.Sent';
$connection = '{' . $server . $port . '/imap' . $no_valid_cert . $ssl . $tls . '}' . $mail_box;
$stream = imap_open($connection, $from, $password);
if ($stream !== FALSE) {
imap_append($stream, $connection, $content);
imap_close($stream);
}
}
示例15: addMessage
/**
* Add a message to the mailbox
*
* @param string $message
*
* @return boolean
*/
public function addMessage($message)
{
return \imap_append($this->connection->getResource(), $this->mailbox, $message);
}