本文整理汇总了PHP中Mail_RFC822类的典型用法代码示例。如果您正苦于以下问题:PHP Mail_RFC822类的具体用法?PHP Mail_RFC822怎么用?PHP Mail_RFC822使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mail_RFC822类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionParse
public static function actionParse()
{
$tolist = 'apple@beta.com,
Michael Ferranti <ferranti.michael@gmail.com>
"Jeff Reifman" <jeff@reifman.org>, <apple@app2.com>,jeff <jeff@smith.com>';
//Yii::import('ext.Mail_RFC822');
include 'Mail/RFC822.php';
$parser = new Mail_RFC822();
// replace the backslash quotes
$tolist = str_replace('\\"', '"', $tolist);
// split the elements by line and by comma
$to_email_array = preg_split("(\r|\n|,)", $tolist, -1, PREG_SPLIT_NO_EMPTY);
$num_emails = count($to_email_array);
echo $num_emails;
for ($count = 0; $count < $num_emails && $count <= 500; $count++) {
$toAddress = trim($to_email_array[$count]);
if ($toAddress != '') {
$addresses = $parser->parseAddressList('my group:' . $toAddress, 'bushsucks.com', false, true);
var_dump($addresses);
lb();
}
//$toAddress=$addresses[0]->mailbox.'@'.$addresses[0]->host;
//if ($this->utilObj->checkEmail($toAddress)) {
// store it or send it or whatever you want to do
//}
}
}
示例2: send
/**
* Send an email message.
*
* @access public
* @param string $to Recipient email address
* @param string $from Sender email address
* @param string $subject Subject line for message
* @param string $body Message body
* @param string $replyTo Someone to reply to
*
* @return mixed PEAR error on error, boolean true otherwise
*/
public function send($to, $from, $subject, $body, $replyTo = null)
{
global $logger;
// Validate sender and recipient
$validator = new Mail_RFC822();
//Allow the to address to be split
$validator->_splitAddresses($to);
foreach ($validator->addresses as $tmpAddress) {
if (!$validator->isValidInetAddress($tmpAddress['address'])) {
return new PEAR_Error('Invalid Recipient Email Address ' . $tmpAddress);
}
}
if (!$validator->isValidInetAddress($from)) {
return new PEAR_Error('Invalid Sender Email Address');
}
$headers = array('To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"');
if (isset($this->settings['fromAddress'])) {
$logger->log("Overriding From address, using " . $this->settings['fromAddress'], PEAR_LOG_INFO);
$headers['From'] = $this->settings['fromAddress'];
$headers['Reply-To'] = $from;
} else {
$headers['From'] = $from;
}
if ($replyTo != null) {
$headers['Reply-To'] = $replyTo;
}
// Get mail object
if ($this->settings['host'] != false) {
$mailFactory = new Mail();
$mail =& $mailFactory->factory('smtp', $this->settings);
if (PEAR_Singleton::isError($mail)) {
return $mail;
}
// Send message
return $mail->send($to, $headers, $body);
} else {
//Mail to false just emits the information to screen
$formattedMail = '';
foreach ($headers as $key => $header) {
$formattedMail .= $key . ': ' . $header . '<br />';
}
$formattedMail .= $body;
$logger->log("Sending e-mail", PEAR_LOG_INFO);
$logger->log("From = {$from}", PEAR_LOG_INFO);
$logger->log("To = {$to}", PEAR_LOG_INFO);
$logger->log($subject, PEAR_LOG_INFO);
$logger->log($formattedMail, PEAR_LOG_INFO);
return true;
}
}
示例3: parseAddressList
function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (!isset($this) || !isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
return $obj->parseAddressList();
}
if (isset($address)) {
$this->address = $address;
}
if (isset($default_domain)) {
$this->default_domain = $default_domain;
}
if (isset($nest_groups)) {
$this->nestGroups = $nest_groups;
}
if (isset($validate)) {
$this->validate = $validate;
}
if (isset($limit)) {
$this->limit = $limit;
}
$this->structure = array();
$this->addresses = array();
$this->error = null;
$this->index = null;
$this->address = preg_replace('/\\r?\\n/', "\r\n", $this->address);
$this->address = preg_replace('/\\r\\n(\\t| )+/', ' ', $this->address);
while ($this->address = $this->_splitAddresses($this->address)) {
}
if ($this->address === false || isset($this->error)) {
require_once 'PEAR.php';
return PEAR::raiseError($this->error);
}
foreach ($this->addresses as $address) {
$valid = $this->_validateAddress($address);
if ($valid === false || isset($this->error)) {
require_once 'PEAR.php';
return PEAR::raiseError($this->error);
}
if (!$this->nestGroups) {
$this->structure = array_merge($this->structure, $valid);
} else {
$this->structure[] = $valid;
}
}
return $this->structure;
}
开发者ID:MMU-TWT-Class-Oct-2015,项目名称:G10B_Sales_of_Point_System_for_Video_and_Audio_shop,代码行数:47,代码来源:RFC822.php
示例4: updateOrCreateEmail
function updateOrCreateEmail($part = '', $opts, $cm = false)
{
// DB_DataObject::debugLevel(1);
$template_name = preg_replace('/\\.[a-z]+$/i', '', basename($opts['file']));
if (!file_exists($opts['file'])) {
$this->jerr("file does not exist : " . $opts['file']);
}
if (!empty($opts['master']) && !file_exists($opts['master'])) {
$this->jerr("master file does not exist : " . $opts['master']);
}
if (empty($cm)) {
$cm = DB_dataObject::factory('core_email');
$ret = $cm->get('name', $template_name);
if ($ret && empty($opts['update'])) {
$this->jerr("use --update 1 to update the template..");
}
}
$mailtext = file_get_contents($opts['file']);
if (!empty($opts['master'])) {
$body = $mailtext;
$mailtext = file_get_contents($opts['master']);
$mailtext = str_replace('{outputBody():h}', $body, $mailtext);
}
require_once 'Mail/mimeDecode.php';
require_once 'Mail/RFC822.php';
$decoder = new Mail_mimeDecode($mailtext);
$parts = $decoder->getSendArray();
if (is_a($parts, 'PEAR_Error')) {
echo $parts->toString() . "\n";
exit;
}
$headers = $parts[1];
$from = new Mail_RFC822();
$from_str = $from->parseAddressList($headers['From']);
$from_name = trim($from_str[0]->personal, '"');
$from_email = $from_str[0]->mailbox . '@' . $from_str[0]->host;
if ($cm->id) {
$cc = clone $cm;
$cm->setFrom(array('bodytext' => $parts[2], 'updated_dt' => date('Y-m-d H:i:s')));
$cm->update($cc);
} else {
$cm->setFrom(array('from_name' => $from_name, 'from_email' => $from_email, 'subject' => $headers['Subject'], 'name' => $template_name, 'bodytext' => $parts[2], 'updated_dt' => date('Y-m-d H:i:s'), 'created_dt' => date('Y-m-d H:i:s')));
$cm->insert();
}
return $cm;
}
示例5: get_mail_addr_array
/**
* アドレスの羅列から名前とメールアドレスの連想配列を取得する
*
* @param $str メールヘッダに含まれるメールアドレスの羅列
* @param メールアドレスの配列
*/
static function get_mail_addr_array($str)
{
// メールアドレスリストとしてparse
$mail_addr_obj_array = Mail_RFC822::parseAddressList($str);
// メールアドレスを格納する配列
$mail_addr_array = array();
foreach ($mail_addr_obj_array as $mail_addr_obj) {
// メールアドレス
$mail_addr = $mail_addr_obj->mailbox . '@' . $mail_addr_obj->host;
array_push($mail_addr_array, $mail_addr);
}
return $mail_addr_array;
}
示例6: valid_email
function valid_email($email)
{
$emailObjects = Mail_RFC822::parseAddressList($email);
if (PEAR::isError($emailObjects)) {
return false;
}
$emailObject = $emailObjects[0];
$email = $emailObject->mailbox . '@' . $emailObject->host;
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
return false;
} else {
return true;
}
}
示例7: register
function register(&$data)
{
$session = Session::singletone();
if (empty($data['user_login'])) {
throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Musisz podaæ login.");
}
if (empty($data['user_pass1']) || empty($data['user_pass2'])) {
throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Has³o nie mo¿e byæ puste.");
}
if (empty($data['user_email'])) {
throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Musisz podaæ email.");
}
$addr = Mail_RFC822::parseAddressList($data['user_email'], "");
if (empty($addr)) {
throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Podany adres email jest nieprawid³owy.");
}
if ($data['user_pass1'] != $data['user_pass2']) {
throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Podane has³a ró¿ni± siê");
}
$user_login = trim($data['user_login']);
$user_pass1 = $data['user_pass1'];
$user_pass2 = $data['user_pass2'];
$user_email = trim($data['user_email']);
$this->_dbo = DB_DataObject::Factory('phph_users');
if (PEAR::isError($this->_dbo)) {
throw new Exception2(_INTERNAL_ERROR, $this->_dbo->getMessage());
}
$r = $this->_dbo->get('user_login', $user_login);
if (PEAR::isError($r)) {
throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
}
if ($r != 0) {
throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Podany login jest ju¿ zajêty.");
}
$this->_dbo->user_login = $user_login;
$this->_dbo->user_pass = md5($user_pass1);
$this->_dbo->user_email = $user_email;
$this->_dbo->user_registered = time();
$this->_dbo->user_activation = md5(uniqid($user_login));
$r = $this->_dbo->insert();
if (PEAR::isError($r)) {
throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
}
return $r;
}
示例8: valid_email
function valid_email($email)
{
$emailObjects = Mail_RFC822::parseAddressList($email);
if (PEAR::isError($emailObjects)) {
return false;
}
// Get the mailbox and host parts of the email object
$mailbox = $emailObjects[0]->mailbox;
$host = $emailObjects[0]->host;
// Make sure the mailbox and host parts aren't too long
if (strlen($mailbox) > 64) {
return false;
}
if (strlen($host) > 255) {
return false;
}
// Validate the mailbox
$atom = '[[:alnum:]_!#$%&\'*+\\/=?^`{|}~-]+';
$dotatom = '(\\.' . $atom . ')*';
$address = '(^' . $atom . $dotatom . '$)';
$char = '([^\\\\"])';
$esc = '(\\\\[\\\\"])';
$text = '(' . $char . '|' . $esc . ')+';
$quoted = '(^"' . $text . '"$)';
$localPart = '/' . $address . '|' . $quoted . '/';
$localMatch = preg_match($localPart, $mailbox);
if ($localMatch === false || $localMatch != 1) {
return false;
}
// Validate the host
$hostname = '([[:alnum:]]([-[:alnum:]]{0,62}[[:alnum:]])?)';
$hostnames = '(' . $hostname . '(\\.' . $hostname . ')*)';
$top = '\\.[[:alnum:]]{2,6}';
$domainPart = '/^' . $hostnames . $top . '$/';
$domainMatch = preg_match($domainPart, $host);
if ($domainMatch === false || $domainMatch != 1) {
return false;
}
return true;
}
示例9: send
/**
* Send an email message.
*
* @param string $to Recipient email address
* @param string $from Sender email address
* @param string $subject Subject line for message
* @param string $body Message body
*
* @return mixed PEAR error on error, boolean true otherwise
* @access public
*/
public function send($to, $from, $subject, $body)
{
// Validate sender and recipient
if (!Mail_RFC822::isValidInetAddress($to)) {
return new PEAR_Error('Invalid Recipient Email Address');
}
if (!Mail_RFC822::isValidInetAddress($from)) {
return new PEAR_Error('Invalid Sender Email Address');
}
// Change error handling behavior to avoid termination during mail
// process....
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
// Get mail object
$mail =& Mail::factory('smtp', $this->settings);
if (PEAR::isError($mail)) {
return $mail;
}
// Send message
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"');
$result = $mail->send($to, $headers, $body);
return $result;
}
示例10: parseAddressList
/**
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
* @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
*
* @return array A structured array of addresses.
*/
function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (!isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
return $obj->parseAddressList();
}
if (isset($address)) {
$this->address = $address;
}
if (isset($default_domain)) {
$this->default_domain = $default_domain;
}
if (isset($nest_groups)) {
$this->nestGroups = $nest_groups;
}
if (isset($validate)) {
$this->validate = $validate;
}
if (isset($limit)) {
$this->limit = $limit;
}
$this->structure = array();
$this->addresses = array();
$this->error = null;
$this->index = null;
while ($this->address = $this->_splitAddresses($this->address)) {
continue;
}
if ($this->address === false || isset($this->error)) {
return $this->raiseError($this->error);
}
// Reset timer since large amounts of addresses can take a long time to
// get here
set_time_limit(30);
// Loop through all the addresses
for ($i = 0; $i < count($this->addresses); $i++) {
if (($return = $this->_validateAddress($this->addresses[$i])) === false || isset($this->error)) {
return $this->raiseError($this->error);
}
if (!$this->nestGroups) {
$this->structure = array_merge($this->structure, $return);
} else {
$this->structure[] = $return;
}
}
return $this->structure;
}
示例11: parseRecipients
/**
* Take a set of recipients and parse them, returning an array of
* bare addresses (forward paths) that can be passed to sendmail
* or an smtp server with the rcpt to: command.
*
* @param mixed Either a comma-seperated list of recipients
* (RFC822 compliant), or an array of recipients,
* each RFC822 valid.
*
* @return array An array of forward paths (bare addresses).
* @access private
*/
function parseRecipients($recipients)
{
include_once 'Mail/RFC822.php';
// if we're passed an array, assume addresses are valid and
// implode them before parsing.
if (is_array($recipients)) {
$recipients = implode(', ', $recipients);
}
// Parse recipients, leaving out all personal info. This is
// for smtp recipients, etc. All relevant personal information
// should already be in the headers.
$addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
$recipients = array();
if (is_array($addresses)) {
foreach ($addresses as $ob) {
$recipients[] = $ob->mailbox . '@' . $ob->host;
}
}
return $recipients;
}
示例12: send
/**
* Sends the mail.
*
* @param array $recipients Array of receipients to send the mail to
* @param string $type How to send the mail ('mail' or 'sendmail' or 'smtp')
* @return mixed
*/
public function send($recipients, $type = 'mail')
{
if (!defined('CRLF')) {
$this->setCRLF(($type == 'mail' or $type == 'sendmail') ? "\n" : "\r\n");
}
$this->build();
switch ($type) {
case 'mail':
$subject = '';
if (!empty($this->headers['Subject'])) {
$subject = $this->encodeHeader($this->headers['Subject'], $this->build_params['head_charset']);
unset($this->headers['Subject']);
}
// Get flat representation of headers
foreach ($this->headers as $name => $value) {
$headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
}
$to = $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
if (!empty($this->return_path)) {
$result = mail($to, $subject, $this->output, implode(CRLF, $headers), '-f' . $this->return_path);
} else {
$result = mail($to, $subject, $this->output, implode(CRLF, $headers));
}
// Reset the subject in case mail is resent
if ($subject !== '') {
$this->headers['Subject'] = $subject;
}
// Return
return $result;
break;
case 'sendmail':
// Get flat representation of headers
foreach ($this->headers as $name => $value) {
$headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
}
// Encode To:
$headers[] = 'To: ' . $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
// Get return path arg for sendmail command if necessary
$returnPath = '';
if (!empty($this->return_path)) {
$returnPath = '-f' . $this->return_path;
}
$pipe = popen($this->sendmail_path . " " . $returnPath, 'w');
$bytes = fputs($pipe, implode(CRLF, $headers) . CRLF . CRLF . $this->output);
$r = pclose($pipe);
return $r;
break;
case 'smtp':
require_once dirname(__FILE__) . '/smtp.php';
require_once dirname(__FILE__) . '/RFC822.php';
$smtp =& smtp::connect($this->smtp_params);
// Parse recipients argument for internet addresses
foreach ($recipients as $recipient) {
$addresses = Mail_RFC822::parseAddressList($recipient, $this->smtp_params['helo'], null, false);
foreach ($addresses as $address) {
$smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host);
}
}
unset($addresses);
// These are reused
unset($address);
// These are reused
// Get flat representation of headers, parsing
// Cc and Bcc as we go
foreach ($this->headers as $name => $value) {
if ($name == 'Cc' or $name == 'Bcc') {
$addresses = Mail_RFC822::parseAddressList($value, $this->smtp_params['helo'], null, false);
foreach ($addresses as $address) {
$smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host);
}
}
if ($name == 'Bcc') {
continue;
}
$headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
}
// Add To header based on $recipients argument
$headers[] = 'To: ' . $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
// Add headers to send_params
$send_params['headers'] = $headers;
$send_params['recipients'] = array_values(array_unique($smtp_recipients));
$send_params['body'] = $this->output;
// Setup return path
if (isset($this->return_path)) {
$send_params['from'] = $this->return_path;
} elseif (!empty($this->headers['From'])) {
$from = Mail_RFC822::parseAddressList($this->headers['From']);
$send_params['from'] = sprintf('%s@%s', $from[0]->mailbox, $from[0]->host);
} else {
$send_params['from'] = 'postmaster@' . $this->smtp_params['helo'];
}
// Send it
if (!$smtp->send($send_params)) {
//.........这里部分代码省略.........
示例13: parseAddressList
/**
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
* @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
*
* @return array A structured array of addresses.
*/
function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (!isset($this) || !isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
return $obj->parseAddressList();
}
if (isset($address)) {
$this->address = $address;
}
if (isset($default_domain)) {
$this->default_domain = $default_domain;
}
if (isset($nest_groups)) {
$this->nestGroups = $nest_groups;
}
if (isset($validate)) {
$this->validate = $validate;
}
if (isset($limit)) {
$this->limit = $limit;
}
$this->structure = array();
$this->addresses = array();
$this->error = null;
$this->index = null;
// Unfold any long lines in $this->address.
$this->address = preg_replace('/\\r?\\n/', "\r\n", $this->address);
$this->address = preg_replace('/\\r\\n(\\t| )+/', ' ', $this->address);
while ($this->address = $this->_splitAddresses($this->address)) {
}
if ($this->address === false || isset($this->error)) {
//require_once 'PEAR.php';
return $this->raiseError($this->error);
}
// Validate each address individually. If we encounter an invalid
// address, stop iterating and return an error immediately.
foreach ($this->addresses as $address) {
$valid = $this->_validateAddress($address);
if ($valid === false || isset($this->error)) {
//require_once 'PEAR.php';
return $this->raiseError($this->error);
}
if (!$this->nestGroups) {
$this->structure = array_merge($this->structure, $valid);
} else {
$this->structure[] = $valid;
}
}
return $this->structure;
}
示例14: getMyProfile
/**
* Get Patron Profile
*
* This is responsible for retrieving the profile for a specific patron.
*
* @param array $patron The patron array
*
* @return mixed Array of the patron's profile data on success,
* PEAR_Error otherwise.
* @access public
*/
public function getMyProfile($patron)
{
$sql = "SELECT PATRON.LAST_NAME, PATRON.FIRST_NAME, " . "PATRON.HISTORICAL_CHARGES, PATRON_ADDRESS.ADDRESS_LINE1, " . "PATRON_ADDRESS.ADDRESS_LINE2, PATRON_ADDRESS.ZIP_POSTAL, " . "PATRON_ADDRESS.CITY, PATRON_ADDRESS.COUNTRY, " . "PATRON_PHONE.PHONE_NUMBER, PATRON_GROUP.PATRON_GROUP_NAME " . "FROM {$this->dbName}.PATRON, {$this->dbName}.PATRON_ADDRESS, " . "{$this->dbName}.PATRON_PHONE, {$this->dbName}.PATRON_BARCODE, " . "{$this->dbName}.PATRON_GROUP " . "WHERE PATRON.PATRON_ID = PATRON_ADDRESS.PATRON_ID (+) " . "AND PATRON_ADDRESS.ADDRESS_ID = PATRON_PHONE.ADDRESS_ID (+) " . "AND PATRON.PATRON_ID = PATRON_BARCODE.PATRON_ID (+) " . "AND PATRON_BARCODE.PATRON_GROUP_ID = " . "PATRON_GROUP.PATRON_GROUP_ID (+) " . "AND PATRON.PATRON_ID = :id";
try {
$sqlStmt = $this->db->prepare($sql);
$this->debugLogSQL(__FUNCTION__, $sql, array(':id' => $patron['id']));
$sqlStmt->execute(array(':id' => $patron['id']));
$patron = array();
while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) {
if (!empty($row['FIRST_NAME'])) {
$patron['firstname'] = utf8_encode($row['FIRST_NAME']);
}
if (!empty($row['LAST_NAME'])) {
$patron['lastname'] = utf8_encode($row['LAST_NAME']);
}
if (!empty($row['PHONE_NUMBER'])) {
$patron['phone'] = utf8_encode($row['PHONE_NUMBER']);
}
if (!empty($row['PATRON_GROUP_NAME'])) {
$patron['group'] = utf8_encode($row['PATRON_GROUP_NAME']);
}
include_once 'Mail/RFC822.php';
$addr1 = utf8_encode($row['ADDRESS_LINE1']);
if (Mail_RFC822::isValidInetAddress($addr1)) {
$patron['email'] = $addr1;
} else {
if (!isset($patron['address1'])) {
if (!empty($addr1)) {
$patron['address1'] = $addr1;
}
if (!empty($row['ADDRESS_LINE2'])) {
$patron['address2'] = utf8_encode($row['ADDRESS_LINE2']);
}
$patron['zip'] = !empty($row['ZIP_POSTAL']) ? utf8_encode($row['ZIP_POSTAL']) : '';
if (!empty($row['CITY'])) {
if ($patron['zip']) {
$patron['zip'] .= ' ';
}
$patron['zip'] .= utf8_encode($row['CITY']);
}
if (!empty($row['COUNTRY'])) {
if ($patron['zip']) {
$patron['zip'] .= ', ';
}
$patron['zip'] .= utf8_encode($row['COUNTRY']);
}
}
}
}
return empty($patron) ? null : $patron;
} catch (PDOException $e) {
return new PEAR_Error($e->getMessage());
}
}
示例15: SendMail
function SendMail($rfc822, $forward = false, $reply = false, $parent = false)
{
debugLog("IMAP-SendMail: " . $rfc822 . "for: {$forward} reply: {$reply} parent: {$parent}");
$mobj = new Mail_mimeDecode($rfc822);
$message = $mobj->decode(array('decode_headers' => false, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\n", 'charset' => 'utf-8'));
$toaddr = $ccaddr = $bccaddr = "";
if (isset($message->headers["to"])) {
$toaddr = $this->parseAddr(Mail_RFC822::parseAddressList($message->headers["to"]));
}
if (isset($message->headers["cc"])) {
$ccaddr = $this->parseAddr(Mail_RFC822::parseAddressList($message->headers["cc"]));
}
if (isset($message->headers["bcc"])) {
$bccaddr = $this->parseAddr(Mail_RFC822::parseAddressList($message->headers["bcc"]));
}
// save some headers when forwarding mails (content type & transfer-encoding)
$headers = "";
$forward_h_ct = "";
$forward_h_cte = "";
$use_orgbody = false;
// clean up the transmitted headers
// remove default headers because we are using imap_mail
$changedfrom = false;
$returnPathSet = false;
$body_base64 = false;
$org_charset = "";
foreach ($message->headers as $k => $v) {
if ($k == "subject" || $k == "to" || $k == "cc" || $k == "bcc") {
continue;
}
if ($k == "content-type") {
// save the original content-type header for the body part when forwarding
if ($forward) {
$forward_h_ct = $v;
continue;
}
// set charset always to utf-8
$org_charset = $v;
$v = preg_replace("/charset=([A-Za-z0-9-\"']+)/", "charset=\"utf-8\"", $v);
}
if ($k == "content-transfer-encoding") {
// if the content was base64 encoded, encode the body again when sending
if (trim($v) == "base64") {
$body_base64 = true;
}
// save the original encoding header for the body part when forwarding
if ($forward) {
$forward_h_cte = $v;
continue;
}
}
// if the message is a multipart message, then we should use the sent body
if (!$forward && $k == "content-type" && preg_match("/multipart/i", $v)) {
$use_orgbody = true;
}
// check if "from"-header is set
if ($k == "from" && !trim($v) && IMAP_DEFAULTFROM) {
$changedfrom = true;
if (IMAP_DEFAULTFROM == 'username') {
$v = $this->_username;
} else {
if (IMAP_DEFAULTFROM == 'domain') {
$v = $this->_domain;
} else {
$v = $this->_username . IMAP_DEFAULTFROM;
}
}
}
// check if "Return-Path"-header is set
if ($k == "return-path") {
$returnPathSet = true;
if (!trim($v) && IMAP_DEFAULTFROM) {
if (IMAP_DEFAULTFROM == 'username') {
$v = $this->_username;
} else {
if (IMAP_DEFAULTFROM == 'domain') {
$v = $this->_domain;
} else {
$v = $this->_username . IMAP_DEFAULTFROM;
}
}
}
}
// all other headers stay
if ($headers) {
$headers .= "\n";
}
$headers .= ucfirst($k) . ": " . $v;
}
// set "From" header if not set on the device
if (IMAP_DEFAULTFROM && !$changedfrom) {
if (IMAP_DEFAULTFROM == 'username') {
$v = $this->_username;
} else {
if (IMAP_DEFAULTFROM == 'domain') {
$v = $this->_domain;
} else {
$v = $this->_username . IMAP_DEFAULTFROM;
}
}
//.........这里部分代码省略.........