本文整理汇总了PHP中Zend\Mail\Message::setEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setEncoding方法的具体用法?PHP Message::setEncoding怎么用?PHP Message::setEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::setEncoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $from
* @param string $name
* @param string | \Zend\View\Model\ViewModel $body
* @param \Zend\View\Renderer\RendererInterface $renderer
*/
public function __construct($from = "", $name = "", RendererInterface $renderer = null)
{
$this->message = new Message();
$this->message->setEncoding(self::DEFAULT_CHARSET);
if ($from) {
$this->message->setFrom($from, $name);
}
$this->renderer = $renderer;
}
示例2: buildMessage
/**
* Build Message
*
* @return MailMessage
*/
public function buildMessage()
{
// prepare html body
$htmlBody = $this->renderer->render($this->viewModel);
// prepare text body
$textBody = $this->buildTextBody($htmlBody);
// prepare subject
$subject = $this->buildSubject($htmlBody);
// prepare html part
$htmlPart = new MimePart($this->buildHtmlHeader() . $htmlBody . $this->buildHtmlFooter());
$htmlPart->type = 'text/html';
// prepare text part
$textPart = new MimePart($textBody);
$textPart->type = 'text/plain';
// prepare mime message
$mailBody = new MimeMessage();
$mailBody->setParts(array($textPart, $htmlPart));
// prepare message
$this->message = new MailMessage();
$this->message->setEncoding($this->encoding);
$this->message->setFrom($this->senderMail, $this->senderName);
$this->message->setSubject($subject);
$this->message->setBody($mailBody);
// return mailer
return $this;
}
示例3: sendEmail
static function sendEmail($emailTo, $emailFrom, $subject, $body, $transport)
{
$message = new Message();
$message->setEncoding('UTF-8')->addTo($emailTo)->addFrom($emailFrom)->setSubject($subject)->setBody($body);
$transport->send($message);
return;
}
示例4: submitAction
public function submitAction()
{
$result = "";
$contact = $this->params()->fromPost();
$captcha = new Captcha(array('name' => 'captcha', 'wordLen' => 6, 'timeout' => 600));
if ($captcha->isValid($_POST['captcha'], $_POST)) {
unset($contact['submit']);
$contact = array_filter($contact);
if ($contact && is_array($contact)) {
$mail = new Mail\Message();
$html = '<p>Contact from Kingsy.co.uk</p><p>=-=-=-=-=-=-=-=-=-=-=-=-=-=</p><p><span></span>From: <span>' . $contact["name"] . '</span></p><p><span></span>Email: <span>' . $contact["email"] . '</span></p><p><span></span>Content<p>' . $contact["content"] . '</p></p>';
$mail->setFrom('contact@kingsy.co.uk', 'Contact Form - Kingsy.co.uk')->addTo("chris@kingsy.co.uk")->setSubject('Contacted');
$bodyPart = new MimeMessage();
$bodyMessage = new MimePart($html);
$bodyMessage->type = 'text/html';
$bodyPart->setParts(array($bodyMessage));
$mail->setBody($bodyPart);
$mail->setEncoding('UTF-8');
try {
$transport = new Mail\Transport\Sendmail();
$transport->send($mail);
$result = true;
} catch (Exception $e) {
print_r($e);
}
} else {
$result = false;
}
} else {
$result = false;
}
return new ViewModel(array('result' => $result));
}
示例5: 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);
}
示例6: send
public function send(SmtpTransport $transport = null, Message $message, array $attachments = array())
{
if ($transport == null) {
$transport = new Sendmail();
}
$content = $message->getBody();
$parts = $attachments;
$parts = array();
$bodyMessage = new \Zend\Mime\Message();
$multiPartContentMessage = new \Zend\Mime\Message();
$text = new Part(html_entity_decode(strip_tags(str_replace("<br />", "\n", $content))));
$text->type = "text/plain";
$text->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$text->charset = 'UTF-8';
$multiPartContentMessage->addPart($text);
$html = new Part($content);
$html->type = Mime::TYPE_HTML;
$html->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$html->charset = 'utf-8';
$multiPartContentMessage->addPart($html);
$multiPartContentMimePart = new Part($multiPartContentMessage->generateMessage());
$multiPartContentMimePart->type = 'multipart/alternative;' . PHP_EOL . ' boundary="' . $multiPartContentMessage->getMime()->boundary() . '"';
$bodyMessage->addPart($multiPartContentMimePart);
foreach ($attachments as $attachment) {
$bodyMessage->addPart($attachment);
}
$message->setBody($bodyMessage);
$message->setEncoding("UTF-8");
$transport->send($message);
}
示例7: setEncoding
public function setEncoding($encoding = null)
{
if ($encoding == null) {
$encoding = $this->mailMessageConfigObj->getEncoding();
}
parent::setEncoding($encoding);
return $this;
}
示例8: sendMessage
protected function sendMessage()
{
$oMessage = new Message();
$oMessage->setEncoding('UTF-8')->addFrom($this->_sFrom)->addTo($this->_sEmailAddress)->setSubject($this->_sSubject)->setBody($this->_oBody);
$oHeaders = $oMessage->getHeaders();
$oHeaders->removeHeader('Content-Type');
$oHeaders->addHeaderLine('Content-Type', 'text/html; charset=UTF-8');
$this->_oTransport->send($oMessage);
$this->clearAll();
}
示例9: testDefaultDateHeaderEncodingIsAlwaysAscii
/**
* @group ZF2-507
*/
public function testDefaultDateHeaderEncodingIsAlwaysAscii()
{
$this->message->setEncoding('utf-8');
$headers = $this->message->getHeaders();
$header = $headers->get('date');
$date = date('r');
$date = substr($date, 0, 16);
$test = $header->getFieldValue();
$test = substr($test, 0, 16);
$this->assertEquals($date, $test);
}
示例10: getNewMessage
/**
* Get a blank email message object.
*
* @return Message
*/
public function getNewMessage()
{
$message = new Message();
$message->setEncoding('UTF-8');
$headers = $message->getHeaders();
$ctype = new ContentType();
$ctype->setType('text/plain');
$ctype->addParameter('charset', 'UTF-8');
$headers->addHeader($ctype);
return $message;
}
示例11: 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;
}
示例12: __invoke
/**
* @param TodoWasMarkedAsExpired $event
* @return void
*/
public function __invoke(TodoWasMarkedAsExpired $event)
{
$todo = $this->todoFinder->findById($event->todoId()->toString());
$user = $this->userFinder->findById($todo->assignee_id);
$message = sprintf('Hi %s! Just a heads up: your todo `%s` has expired on %s.', $user->name, $todo->text, $todo->deadline);
$mail = new Mail\Message();
$mail->setBody($message);
$mail->setEncoding('utf-8');
$mail->setFrom('reminder@getprooph.org', 'Proophessor-do');
$mail->addTo($user->email, $user->name);
$mail->setSubject('Proophessor-do Todo expired');
$this->mailer->send($mail);
}
示例13: feedbackAction
/**
* Create record feedback form and send feedback to correct recipient.
*
* @return mixed
* @throws \Exception
*/
public function feedbackAction()
{
$view = $this->createViewModel();
if ($this->formWasSubmitted('submitFeedback')) {
$flashMsg = $this->flashMessenger();
$message = $this->params()->fromPost('feedback_message');
$senderEmail = $this->params()->fromPost('from');
$validator = new \Zend\Validator\EmailAddress();
if (!$validator->isValid($senderEmail)) {
$flashMsg->setNamespace('error')->addMessage('Email address is invalid');
return $view;
}
$driver = $this->loadRecord();
$dataSource = $driver->getDataSource();
$dataSources = $this->getServiceLocator()->get('VuFind\\Config')->get('datasources');
$inst = isset($dataSources->{$dataSource}) ? $dataSources->{$dataSource} : null;
$recipientEmail = isset($inst->feedbackEmail) ? $inst->feedbackEmail : null;
if ($recipientEmail == null) {
throw new \Exception('Feedback Module Error:' . 'Recipient Email Unset (see datasources.ini)');
}
$emailSubject = $this->translate('feedback_on_record', ['%%record%%' => $driver->getBreadcrumb()]);
$serverUrl = $this->getRequest()->getServer('REQUEST_SCHEME');
$serverUrl .= '://' . $this->getRequest()->getServer('HTTP_HOST');
$emailMessage = "\n" . $this->translate('This email was sent from');
$emailMessage .= ": " . $senderEmail . "\n";
$emailMessage .= "------------------------------------------------------------\n";
$emailMessage .= $this->getViewRenderer()->partial('RecordDriver/SolrDefault/result-email.phtml', ['driver' => $driver, 'info' => ['baseUrl' => $serverUrl]]);
$emailMessage .= "------------------------------------------------------------\n";
if (!empty($message)) {
$emailMessage .= "\n" . $this->translate('Message From Sender') . ":\n";
$emailMessage .= "\n" . $message . "\n\n";
}
// This sets up the email to be sent
$mail = new Mail\Message();
$mail->setEncoding('UTF-8');
$mail->setBody($emailMessage);
$mail->setFrom($senderEmail);
$mail->addTo($recipientEmail);
$mail->setSubject($emailSubject);
$headers = $mail->getHeaders();
$headers->removeHeader('Content-Type');
$headers->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8');
$this->getServiceLocator()->get('VuFind\\Mailer')->getTransport()->send($mail);
if (!$this->inLightbox()) {
$flashMsg->setNamespace('info')->addMessage('Thank you for your feedback');
$this->redirectToRecord('');
}
}
return $view;
}
示例14: addMail
public function addMail($to, $from, $subject, $body)
{
$message = new Message();
$bodyPart = new MimeMessage();
$bodyMessage = new MimePart($body);
$bodyMessage->type = 'text/html';
$bodyMessage->charset = 'UTF-8';
$bodyPart->setParts([$bodyMessage]);
$message->setFrom($from);
$message->addTo($to);
$message->setEncoding("UTF-8");
$message->setSubject($subject);
$message->setBody($bodyPart);
$message->type = 'text/html';
$this->queue[] = $message;
}
示例15: send
public function send()
{
$this->initialise();
$body = new MimeMessage();
$htmlPart = new MimePart($this->body);
$htmlPart->type = "text/html";
$partArray = array($htmlPart);
$body->setParts($partArray);
$message = new Mail\Message();
$message->setFrom($this->from);
$message->addTo($this->to);
$message->setSubject($this->subject);
$message->setEncoding("UTF-8");
$message->setBody($body);
$transport = $this->getTransport();
$transport->send($message);
}