本文整理匯總了PHP中Zend\Mail\Message::from方法的典型用法代碼示例。如果您正苦於以下問題:PHP Message::from方法的具體用法?PHP Message::from怎麽用?PHP Message::from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::from方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepareFromAddress
/**
* Retrieve email address for envelope FROM
*
* @param Message $message
* @return string
*/
protected function prepareFromAddress(Message $message)
{
$sender = $message->getSender();
if ($sender instanceof AddressDescription) {
return $sender->getEmail();
}
$from = $message->from();
if (!count($from)) {
throw new Exception\RuntimeException(sprintf('%s transport expects either a Sender or at least one From address in the Message; none provided', __CLASS__));
}
$from->rewind();
$sender = $from->current();
return $sender->getEmail();
}
示例2: prepareParameters
/**
* Prepare additional_parameters argument
*
* Basically, overrides the MAIL FROM envelope with either the Sender or
* From address.
*
* @param Message $message
* @return string
*/
protected function prepareParameters(Message $message)
{
if ($this->isWindowsOs()) {
return null;
}
$parameters = (string) $this->parameters;
$sender = $message->getSender();
if ($sender instanceof AddressDescription) {
$parameters .= ' -r ' . $sender->getEmail();
return $parameters;
}
$from = $message->from();
if (count($from)) {
$from->rewind();
$sender = $from->current();
$parameters .= ' -r ' . $sender->getEmail();
return $parameters;
}
return $parameters;
}