本文整理汇总了PHP中Zend\Mail\Message::getSender方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getSender方法的具体用法?PHP Message::getSender怎么用?PHP Message::getSender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::getSender方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanProvideAddressObjectWhenSettingSender
public function testCanProvideAddressObjectWhenSettingSender()
{
$sender = new Address('zf-devteam@zend.com');
$this->message->setSender($sender);
$test = $this->message->getSender();
$this->assertSame($sender, $test);
}
示例2: convert
/**
*
* @param Message $message
* @return ZendMessage
*/
public static function convert(Message $message)
{
$mailMessage = new ZendMessage();
$mailMessage->setSubject($message->getSubject());
$mailMessage->setFrom($message->getFrom());
$mailMessage->setTo($message->getTo());
$mailMessage->setCc($message->getCc());
$mailMessage->setBcc($message->getBcc());
$mailMessage->setReplyTo($message->getReplyTo());
$mailMessage->getHeaders()->addHeaders($message->getHeaders());
if ($mailMessage->getSender()) {
$mailMessage->setSender($message->getSender());
}
if ($message->isMultipart()) {
$mimePart = new MimeMessage();
if ($message->getBodyHtml()) {
$part = new Part($message->getBodyHtml());
$part->charset = $message->getCharset();
$part->encoding = $message->getEncoding();
$part->type = Mime::TYPE_HTML;
$mimePart->addPart($part);
}
if ($message->getBodyText()) {
$part = new Part($message->getBodyText());
$part->charset = $message->getCharset();
$part->encoding = $message->getEncoding();
$part->type = Mime::TYPE_TEXT;
$mimePart->addPart($part);
}
foreach ($message->getAttachments() as $attachment) {
$mimePart->addPart($attachment->asMimePart());
}
foreach ($message->getParts() as $part) {
$mimePart->addPart($part);
}
$mailMessage->setBody($mimePart);
} else {
$mailMessage->getHeaders()->addHeaderLine('Content-Type', $message->getContentType());
$mailMessage->setEncoding($message->getEncoding());
$mailMessage->setBody($message->getFilledBody());
}
return $mailMessage;
}
示例3: send
/**
* @param Message $message
* @param null $transport
* @return mixed
*/
public function send(Message $message, $transport = null)
{
if (!$message->getSender()) {
$sender = $transport ? $transport : 'default';
$emailAddress = $this->getOption('addressList')[$sender];
$message->setSender($emailAddress['address'], $emailAddress['name']);
}
return $this->getMailTransport($transport)->send($message);
}
示例4: 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();
}
示例5: prepareParameters
/**
* Prepare additional_parameters argument
*
* Basically, overrides the MAIL FROM envelope with either the Sender or
* From address.
*
* @param \Zend\Mail\Message $message
* @return string
*/
protected function prepareParameters(Mail\Message $message)
{
if ($this->isWindowsOs()) {
return null;
}
$parameters = (string) $this->parameters;
$sender = $message->getSender();
if ($sender instanceof AddressInterface) {
$parameters .= ' -f ' . $sender->getEmail();
return $parameters;
}
$from = $message->getFrom();
if (count($from)) {
$from->rewind();
$sender = $from->current();
$parameters .= ' -f ' . $sender->getEmail();
return $parameters;
}
return $parameters;
}
示例6: prepareFromAddress
/**
* Retrieve email address for envelope FROM
*
* @param Message $message
* @throws Exception\RuntimeException
* @return string
*/
protected function prepareFromAddress(Message $message)
{
if ($this->getEnvelope() && $this->getEnvelope()->getFrom()) {
return $this->getEnvelope()->getFrom();
}
$sender = $message->getSender();
if ($sender instanceof Address\AddressInterface) {
return $sender->getEmail();
}
$from = $message->getFrom();
if (!count($from)) {
// Per RFC 2822 3.6
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();
}