本文整理匯總了PHP中Nette\Mail\Message::getEncodedHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP Message::getEncodedHeader方法的具體用法?PHP Message::getEncodedHeader怎麽用?PHP Message::getEncodedHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Mail\Message
的用法示例。
在下文中一共展示了Message::getEncodedHeader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send
/**
* Sends email.
* @param Message
* @return void
*/
public function send(Message $mail)
{
$tmp = clone $mail;
$tmp->setHeader('Subject', NULL);
$tmp->setHeader('To', NULL);
$parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
Nette\Diagnostics\Debugger::tryError();
$res = mail(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]), (string) $this->commandArgs);
if (Nette\Diagnostics\Debugger::catchError($e)) {
throw new Nette\InvalidStateException('mail(): ' . $e->getMessage(), 0, $e);
} elseif (!$res) {
throw new Nette\InvalidStateException('Unable to send email.');
}
}
示例2: send
/**
* Sends email.
* @return void
*/
public function send(Message $mail)
{
$tmp = clone $mail;
$tmp->setHeader('Subject', NULL);
$tmp->setHeader('To', NULL);
$parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
$args = array(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]));
if ($this->commandArgs) {
$args[] = (string) $this->commandArgs;
}
if (call_user_func_array('mail', $args) === FALSE) {
$error = error_get_last();
throw new Nette\InvalidStateException("Unable to send email: {$error['message']}.");
}
}
示例3: send
/**
* Sends email.
* @return void
*/
public function send(Message $mail)
{
$tmp = clone $mail;
$tmp->setHeader('Subject', NULL);
$tmp->setHeader('To', NULL);
$parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
$args = array(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]));
if ($this->commandArgs) {
$args[] = (string) $this->commandArgs;
}
$res = Nette\Utils\Callback::invokeSafe('mail', $args, function ($message) use(&$info) {
$info = ": {$message}";
});
if ($res === FALSE) {
throw new Nette\InvalidStateException("Unable to send email{$info}.");
}
}
示例4: send
/**
* Sends email.
* @return void
*/
public function send(Message $mail)
{
$tmp = clone $mail;
$tmp->setHeader('Subject', NULL);
$tmp->setHeader('To', NULL);
$parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
$args = array(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]));
if ($this->commandArgs) {
$args[] = (string) $this->commandArgs;
}
set_error_handler(function ($severity, $message) use(&$info) {
$info = ": {$message}";
});
$res = call_user_func_array('mail', $args);
restore_error_handler();
if ($res === FALSE) {
throw new Nette\InvalidStateException("Unable to send email{$info}.");
}
}