本文整理汇总了PHP中Zend\Mail\Message::setReplyTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setReplyTo方法的具体用法?PHP Message::setReplyTo怎么用?PHP Message::setReplyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::setReplyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send($fromAddress, $fromName, $replyToAddress, $replyToName, $toAddress, $toName, $subject, array $mimeParts)
{
$mail = new Message();
if ($fromAddress && $fromName) {
$mail->setFrom($fromAddress, $fromName);
} else {
if ($fromAddress) {
$mail->setFrom($fromAddress);
}
}
if ($replyToAddress && $replyToName) {
$mail->setReplyTo($replyToAddress, $replyToName);
} else {
if ($replyToAddress) {
$mail->setReplyTo($replyToAddress);
}
}
if ($toAddress && $toName) {
$mail->setTo($toAddress, $toName);
} else {
if ($toAddress) {
$mail->setTo($toAddress);
}
}
$mail->setSubject($subject);
$mail->setEncoding('utf-8');
$mime = new MimeMessage();
$mime->setParts($mimeParts);
$mail->setBody($mime);
$this->mailTransport->send($mail);
$this->getEventManager()->trigger('send', $mail);
}
示例2: fromWrappedMessage
/**
* @inheritDoc
*/
public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
{
if (!$wrappedMessage instanceof MailWrappedMessage) {
throw new MailWrapperSetupException('Not MailWrappedMessage');
}
$message = new Message();
foreach ($wrappedMessage->getToRecipients() as $address) {
$message->addTo($address);
}
foreach ($wrappedMessage->getCcRecipients() as $address) {
$message->addCc($address);
}
foreach ($wrappedMessage->getBccRecipients() as $address) {
$message->addBcc($address);
}
$message->setReplyTo($wrappedMessage->getReplyTo());
$message->setFrom($wrappedMessage->getFrom());
$message->setSubject($wrappedMessage->getSubject());
if ($wrappedMessage->getContentText()) {
$message->setBody($wrappedMessage->getContentText());
}
if ($wrappedMessage->getContentHtml()) {
$html = new MimePart($wrappedMessage->getContentHtml());
$html->type = "text/html";
$message->setBody($body);
}
return $message;
}
示例3: setReplyTo
public function setReplyTo($emailOrAddressList = null, $name = null)
{
if ($emailOrAddressList == null && $name == null) {
$emailOrAddressList = $this->mailMessageConfigObj->getReplyTo();
$name = $this->mailMessageConfigObj->getReplyName();
}
parent::setReplyTo($emailOrAddressList, $name);
return $this;
}
示例4: testCanSetReplyToListFromAddressList
public function testCanSetReplyToListFromAddressList()
{
$list = new AddressList();
$list->add('zf-devteam@zend.com');
$this->message->addReplyTo('fw-announce@lists.zend.com');
$this->message->setReplyTo($list);
$replyTo = $this->message->getReplyTo();
$this->assertEquals(1, count($replyTo));
$this->assertFalse($replyTo->has('fw-announce@lists.zend.com'));
$this->assertTrue($replyTo->has('zf-devteam@zend.com'));
}
示例5: createMessage
/**
* @param ZendMailInterface $mail
*
* @return Mail\Message
*/
protected function createMessage(ZendMailInterface $mail)
{
$message = new Mail\Message();
$message->getHeaders()->addHeaders($mail->getHeaders());
$message->setTo($mail->getTo());
$message->setCc($mail->getCc());
$message->setBcc($mail->getBcc());
$message->setFrom($mail->getFrom());
$message->setReplyTo($mail->getReplyTo());
$message->setSubject($mail->getSubject());
$message->setBody($this->messageCreator->createMessage($mail));
return $message;
}
示例6: sendMessage
protected function sendMessage($destinations, $from, $subject, Mime\Message $body, $headers = false)
{
$message = new Mail\Message();
$message->setFrom($this->alwaysFrom ? $this->alwaysFrom : $from);
$message->setSubject($subject);
$message->setBody($body);
$message->setReplyTo($from);
if (isset($destinations)) {
$destinations = is_array($destinations) ? $destinations : explode(',', $destinations);
} else {
$destinations = array();
}
//Set our headers. If we find CC or BCC emails add them to the Destinations array
if (!isset($headers['To'])) {
$headers['To'] = implode('; ', $destinations);
}
if (isset($headers['Cc'])) {
$destinations = array_merge($destinations, explode(',', $headers['Cc']));
}
if (isset($headers['Bcc'])) {
$destinations = array_merge($destinations, explode(',', $headers['Bcc']));
}
// if a custom 'reply-to' address has been set via headers
if (isset($headers['Reply-To'])) {
$message->setReplyTo($headers['Reply-To']);
unset($headers['Reply-To']);
}
if ($headers) {
$message->getHeaders()->addHeaders($headers);
}
//if no Destinations address is set SES will reject the email.
if (!array_filter($destinations)) {
throw new LogicException('No Destinations (To, Cc, Bcc) for email set.');
}
try {
$response = $this->client->sendRawEmail(array('Destinations' => $destinations, 'RawMessage' => array('Data' => $this->getMessageText($message))));
} catch (\Aws\Ses\Exception\SesException $ex) {
return false;
}
/* @var $response Aws\Result */
if (isset($response['MessageId']) && strlen($response['MessageId'])) {
return true;
}
}
示例7: 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;
}
示例8: getMessage
/**
* @param string $tpl
* @param array $data
* @return Message
*/
public function getMessage($tpl, array $data)
{
$mail = new Message();
$mail->setEncoding('UTF-8');
if (isset($data['encoding'])) {
$mail->setEncoding($data['encoding']);
}
if (isset($data['from_address'])) {
if (isset($data['from_name'])) {
$mail->setFrom($data['from_address'], $data['from_name']);
} else {
$mail->setFrom($data['from_address']);
}
}
if (isset($data['to'])) {
if (isset($data['to_name'])) {
$mail->setTo($data['to'], $data['to_name']);
} else {
$mail->setTo($data['to']);
}
}
if (isset($data['cc'])) {
$mail->setCc($data['cc']);
}
if (isset($data['bcc'])) {
$mail->setBcc($data['bcc']);
}
if (isset($data['subject'])) {
$mail->setSubject($data['subject']);
}
if (isset($data['sender'])) {
$mail->setSender($data['sender']);
}
if (isset($data['replyTo'])) {
$mail->setReplyTo($data['replyTo']);
}
$content = $this->renderMail($tpl, $data);
$mail->setBody($content);
$mail->getHeaders()->addHeaderLine('Content-Type', 'text/html; charset=UTF-8')->addHeaderLine('Content-Transfer-Encoding', '8bit');
return $mail;
}
示例9: send
public static function send($config = [])
{
if (!empty($config['smtp'])) {
$transport = new SmtpTransport(new SmtpOptions(['name' => $config['smtp']['name'], 'host' => $config['smtp']['host'], 'port' => $config['smtp']['port'], 'connection_class' => 'login', 'connection_config' => ['username' => $config['smtp']['username'], 'password' => $config['smtp']['password'], 'ssl' => $config['smtp']['ssl']]]));
} else {
$param = '';
if (!empty($config['returnPath'])) {
$param = sprintf('-r%s', $config['returnPath']);
}
$transport = new SendmailTransport($param);
}
$message = new Message();
$message->setEncoding($config['charset']);
foreach ($config['from'] as $email => $name) {
$message->setFrom($email, $name);
break;
}
foreach ($config['to'] as $email => $name) {
$message->addTo($email, $name);
}
if (empty($config['replyTo'])) {
$config['replyTo'] = $config['from'];
}
foreach ($config['replyTo'] as $email => $name) {
$message->setReplyTo($email, $name);
break;
}
$message->setSubject($config['subject']);
$htmlBody = '';
if (!empty($config['html'])) {
$htmlBody = $config['html'];
} elseif (!empty($config['template'])) {
$htmlBody = file_get_contents($config['template']);
foreach ($config['fields'] as $field => $label) {
$htmlBody = str_replace(sprintf('{$%s}', $field), $config['post'][$field], $htmlBody);
}
} else {
$htmlBody .= str_repeat('= ', $config['lineWidth'] / 2) . PHP_EOL;
$maxWidth = 0;
foreach ($config['fields'] as $field => $label) {
$currentWidth = mb_strlen($label);
if ($currentWidth > $maxWidth) {
$maxWidth = $currentWidth;
}
}
foreach ($config['fields'] as $field => $label) {
$htmlBody .= sprintf('<strong>%s:</strong> %s', str_pad($label, $maxWidth, '.', STR_PAD_RIGHT), $config['post'][$field]) . PHP_EOL;
}
$htmlBody .= str_repeat('= ', $config['lineWidth'] / 2);
$htmlBody = '
<html>
<body>
<table>
<tr>
<td>
<div style="font-family: \'courier new\', courier, monospace; font-size: 14px;">' . nl2br($htmlBody) . '</div>
</td>
</tr>
</table>
</body>
</html>';
}
$html = new MimePart($htmlBody);
$html->type = 'text/html';
$body = new MimeMessage();
$body->setParts([$html]);
$message->setBody($body);
try {
$transport->send($message);
return true;
} catch (RuntimeException $e) {
return false;
}
}
示例10: createMessage
/**
* @return Message
*/
protected function createMessage()
{
$options = $this->mailOptions->getMessageOptions();
// Prepare Mail Message
$message = new Message();
$from = $options->getFrom();
if (!empty($from)) {
$message->setFrom($from, $options->getFromName());
}
$replyTo = $options->getReplyTo();
if (!empty($replyTo)) {
$message->setReplyTo($replyTo, $options->getReplyToName());
}
$to = $options->getTo();
if (!empty($to)) {
$message->setTo($to);
}
$cc = $options->getCc();
if (!empty($cc)) {
$message->setCc($cc);
}
$bcc = $options->getBcc();
if (!empty($bcc)) {
$message->setBcc($bcc);
}
return $message;
}
示例11: _constructEmail
/**
* Create a email based on it's theme an params
*
* @param string $address
* @param string $name
* @throws Exception
* @return \Zend\Mail\Message
*/
protected function _constructEmail($address, $name)
{
$content = $this->_template->render();
if ('' == $this->_replyTo) {
$this->_replyTo = $this->_template->getTestament()->getReplyTo();
}
if ('' == $this->_fromName) {
$this->_fromName = $this->_template->getTestament()->getFromName();
}
if ('' == $this->_fromAddress) {
$this->_fromAddress = $this->_template->getTestament()->getFromAddress();
}
if ('' == $this->_subject) {
$this->_subject = $this->_template->getTestament()->getFromAddress();
}
$contentParts = array();
$partText = new Part($content->getText());
$partText->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$partText->type = Mime::TYPE_TEXT;
$contentParts[] = $partText;
$partHtml = new Part($content->getHtml());
$partHtml->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$partHtml->type = Mime::TYPE_HTML;
$partHtml->charset = 'UTF-8';
$contentParts[] = $partHtml;
$alternatives = new \Zend\Mime\Message();
$alternatives->setParts($contentParts);
$alternativesPart = new Part($alternatives->generateMessage());
$alternativesPart->type = "multipart/alternative; boundary=\"" . $alternatives->getMime()->boundary() . "\"";
$body = new \Zend\Mime\Message();
$body->addPart($alternativesPart);
foreach ($this->_attachments as $attachmentSrc) {
$attachment = new Part(fopen($attachmentSrc['filelocation'], 'r'));
$attachment->filename = $attachmentSrc['filename'];
$attachment->encoding = Mime::ENCODING_BASE64;
$attachment->type = Mime::DISPOSITION_ATTACHMENT;
$attachment->disposition = true;
$body->addPart($attachment);
}
$subject = $this->_subject;
foreach ($this->_variables as $name => $variable) {
$subject = str_replace('{{:' . $name . ':}}', $variable, $subject);
}
$message = new Message();
$message->setSubject($subject);
$message->setFrom($this->_fromAddress, $this->_fromName);
if ($this->_replyTo) {
$message->setReplyTo($this->_replyTo);
}
$message->setBody($body);
$message->setTo($address, $name);
$message->setEncoding("UTF-8");
return $message;
}
示例12: sendMail
/**
* @param string $templateName
* @param string $email
* @param array $params
* @return boolean
*/
public function sendMail($templateName, $email, array $params = array())
{
$config = $this->getServiceLocator()->get('Config');
$settings = $this->getServiceLocator()->get('Settings');
/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
if (!isset($config['mailer']['templates_path'])) {
throw new \Exception('Mail templates path is not set');
}
// get from addresss
if (!isset($params['from'])) {
$params['from'] = $settings->get('mail:from');
}
$from = $params['from'];
if ($from == '') {
throw new \Exception('Can\'t send mail - from address not given');
}
// get language
if (!isset($params['language']) || $params['language'] == '') {
throw new \Exception('Can\'t send mail - language not given');
}
$language = $params['language'];
// get mail template
// $templatesTable = $this->getServiceLocator()->get('Msingi\Cms\Db\Table\MailTemplates');
$templates_repository = $entityManager->getRepository('Msingi\\Cms\\Entity\\MailTemplate');
$template = $templates_repository->fetchOrCreate($templateName);
/** @var \Msingi|Cms\Repository\MailTemplatesI18n $templates_i18n_repository */
$templates_i18n_repository = $entityManager->getRepository('Msingi\\Cms\\Entity\\MailTemplateI18n');
/** @var \Msingi\Cms\Entity\MailTemplateI18n $i18n */
$i18n = $templates_i18n_repository->fetchOrCreate($template, $language);
// replace tokens
$subject = $this->processTokens($i18n->getSubject(), $params);
$message = $this->processTokens($i18n->getTemplate(), $params);
// initialize renderer
$renderer = new PhpRenderer();
$resolver = new Resolver\AggregateResolver();
$renderer->setResolver($resolver);
$stack = new Resolver\TemplatePathStack(array('script_paths' => array($config['mailer']['templates_path'])));
$resolver->attach($stack);
// render message template
$messageHtml = $renderer->render('default', array('content' => $message));
// get text content of the message
$html2text = new HTML2Text();
$html2text->html2text($messageHtml);
// create text message part
$messageTextPart = new Mime\Part($html2text->get_text());
$messageTextPart->type = 'text/plain';
// create html message part
$messageHtmlPart = new Mime\Part($messageHtml);
$messageHtmlPart->type = 'text/html';
// create message body
$messageBody = new Mime\Message();
$messageBody->setParts(array($messageTextPart, $messageHtmlPart));
// @todo Implement attachements
//
$mail = new Mail\Message();
$mail->setFrom($from);
if (isset($params['reply-to']) && $params['reply-to'] != '') {
$mail->setReplyTo($params['reply-to']);
}
$mail->addTo($email);
$mail->setEncoding('UTF-8');
$mail->setSubject($subject);
$mail->setBody($messageBody);
$mail->getHeaders()->get('Content-Type')->setType('multipart/alternative');
//
$mailer_config = $config['mailer'];
// log message
if ($settings->get('mail:log')) {
if (!is_dir($config['mailer']['log_dir'])) {
mkdir($config['mailer']['log_dir']);
}
$transport = new \Zend\Mail\Transport\File();
$options = new \Zend\Mail\Transport\FileOptions(array('path' => $config['mailer']['log_dir'], 'callback' => function (\Zend\Mail\Transport\File $transport) use($templateName) {
return date('Ymd.His') . '-' . $templateName . '-' . mt_rand() . '.txt';
}));
$transport->setOptions($options);
$transport->send($mail);
}
// send message
if ($settings->get('mail:send')) {
if (isset($mailer_config['transport']) && $mailer_config['transport'] == 'smtp') {
$transport = new SmtpTransport();
$options = new Mail\Transport\SmtpOptions($mailer_config['smtp_options']);
$transport->setOptions($options);
} else {
$transport = new SendmailTransport();
}
$transport->send($mail);
}
return true;
}
示例13: send
public function send(Email $email, $params = array(), &$message = null, $attachmetList = [])
{
if (!$message) {
$message = new Message();
}
$config = $this->config;
$params = $this->params + $params;
if ($email->get('from')) {
$fromName = null;
if (!empty($params['fromName'])) {
$fromName = $params['fromName'];
} else {
$fromName = $config->get('outboundEmailFromName');
}
$message->addFrom(trim($email->get('from')), $fromName);
} else {
if (!empty($params['fromAddress'])) {
$fromAddress = $params['fromAddress'];
} else {
if (!$config->get('outboundEmailFromAddress')) {
throw new Error('outboundEmailFromAddress is not specified in config.');
}
$fromAddress = $config->get('outboundEmailFromAddress');
}
if (!empty($params['fromName'])) {
$fromName = $params['fromName'];
} else {
$fromName = $config->get('outboundEmailFromName');
}
$message->addFrom($fromAddress, $fromName);
}
if (!$email->get('from')) {
$email->set('from', $fromAddress);
}
if (!empty($params['replyToAddress'])) {
$replyToName = null;
if (!empty($params['replyToName'])) {
$replyToName = $params['replyToName'];
}
$message->setReplyTo($params['replyToAddress'], $replyToName);
}
$value = $email->get('to');
if ($value) {
$arr = explode(';', $value);
if (is_array($arr)) {
foreach ($arr as $address) {
$message->addTo(trim($address));
}
}
}
$value = $email->get('cc');
if ($value) {
$arr = explode(';', $value);
if (is_array($arr)) {
foreach ($arr as $address) {
$message->addCC(trim($address));
}
}
}
$value = $email->get('bcc');
if ($value) {
$arr = explode(';', $value);
if (is_array($arr)) {
foreach ($arr as $address) {
$message->addBCC(trim($address));
}
}
}
$value = $email->get('replyTo');
if ($value) {
$arr = explode(';', $value);
if (is_array($arr)) {
foreach ($arr as $address) {
$message->addReplyTo(trim($address));
}
}
}
$attachmentPartList = array();
$attachmentCollection = $email->get('attachments');
$attachmentInlineCollection = $email->getInlineAttachments();
foreach ($attachmetList as $attachment) {
$attachmentCollection[] = $attachment;
}
if (!empty($attachmentCollection)) {
foreach ($attachmentCollection as $a) {
$fileName = 'data/upload/' . $a->id;
$attachment = new MimePart(file_get_contents($fileName));
$attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Mime::ENCODING_BASE64;
$attachment->filename = $a->get('name');
if ($a->get('type')) {
$attachment->type = $a->get('type');
}
$attachmentPartList[] = $attachment;
}
}
if (!empty($attachmentInlineCollection)) {
foreach ($attachmentInlineCollection as $a) {
$fileName = 'data/upload/' . $a->id;
$attachment = new MimePart(file_get_contents($fileName));
//.........这里部分代码省略.........
示例14: email
/**
* Metodo para envio de email pelo sistema. As configuracoes de conexao com o servidor de email
* devem estar no arquivo 'config/autoload/'.$type.'.local.php'.
* Ps.: Este arquivo, por conter senhas, é ignorado pelo git.
*
* @param string|array $emailTo
* @param string $subject
* @param string $htmlBody
* @param string $type
* @param string|array $replyTo
* @throws Exception
*/
protected function email($emailTo, $subject, $htmlBody, $type = 'mail', $replyTo = null)
{
$result = true;
/**
* O arquivo *.local.php nao eh incluido no git, por isso as informacoes contidas
* nele sao seguras, diferente do arquivo global.php.
*/
$auth = 'config/autoload/' . $type . '.local.php';
$authConf = file_exists($auth) ? require $auth : false;
$global = (require 'config/autoload/global.php');
$options = array_merge_recursive(isset($global[$type]) ? $global[$type] : array(), $authConf);
try {
if ($options) {
// Codifica o tipo de mensagem HTML
$mimePart = new Mime\Part($htmlBody);
$mimePart->type = Mime\Mime::TYPE_HTML;
$mimeMsg = new Mime\Message();
$mimeMsg->setParts(array($mimePart));
// Cria mensagem efetivamente
$message = new Message();
$message->setBody($mimeMsg);
$message->setEncoding('UTF-8');
// Informacoes do e-mail em si
$message->addFrom($options['connection_config']['username'], 'Braghim Sistemas');
if ($replyTo) {
$message->setReplyTo($replyTo);
}
$message->addTo($emailTo);
$message->setSubject($subject);
// Transportador de mensagem
$transport = new SmtpTransport();
$transport->setOptions(new SmtpOptions($options));
$transport->send($message);
} else {
throw new \Exception("Configurações de e-mail não foram definidas ou arquivo '{$type}.local.php' não existe");
}
} catch (\Exception $e) {
Firephp::getInstance()->err($e->__toString());
$result = false;
}
return $result;
}
示例15: setReplyTo
function setReplyTo($email, $name = null)
{
$this->mail->setReplyTo($email, $name);
}