本文整理汇总了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}.");
}
}