本文整理汇总了PHP中Swift_Message::setSubject方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Message::setSubject方法的具体用法?PHP Swift_Message::setSubject怎么用?PHP Swift_Message::setSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_Message
的用法示例。
在下文中一共展示了Swift_Message::setSubject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMessage
public function sendMessage()
{
$transport = \Swift_SmtpTransport::newInstance($this->mta->address, $this->mta->port);
$swift = \Swift_Mailer::newInstance($transport);
$message = new \Swift_Message();
$headers = $message->getHeaders();
$headers->addTextHeader('X-GreenArrow-MailClass', 'SIGMA_NEWEMKTG_DEVEL');
$message->setSubject($this->data->subject);
$message->setFrom(array($this->data->fromEmail => $this->data->fromName));
$message->setBody($this->html, 'text/html');
$message->addPart($this->plainText, 'text/plain');
$this->logger->log("Crea contenido del correo para enviar");
foreach ($this->data->target as $to) {
$message->setTo($to);
$this->logger->log("Preparandose para enviar mensaje a: {$to}");
$recipients = $swift->send($message, $failures);
if ($recipients) {
\Phalcon\DI::getDefault()->get('logger')->log('Recover Password Message successfully sent!');
} else {
throw new Exception('Error while sending message: ' . $failures);
}
}
}
示例2: _setMessage
/**
* Создаём основу сообщения
*/
private function _setMessage()
{
$to = $this->_args['email'];
$from = $this->_args['from'];
$subj = $this->_args['subject'];
$body = $this->_args['body'];
$this->_message->setSubject($subj)->setFrom($from)->setTo($to)->setBody($body, 'text/plain');
}
示例3: send
/**
* @param string $subject
* @param string $body
* @param array|string $to
* @param array|string $from
* @param array|Attachment|null $attachments
* @return int
*/
public function send($subject, $body, $to, $from, $attachments = null)
{
$this->message->setSubject($subject);
$this->message->setFrom($from);
$this->message->setTo($to);
$this->message->setBody($body, self::BODY_TYPE);
$this->processAttachments($attachments);
return $this->mailer->send($this->message);
}
示例4: transformMessage
/**
* Creates a swift message from a ParsedMessage, handles defaults
*
* @param ParsedMessage $parsedMessage
*
* @return \Swift_Message
*/
protected function transformMessage(ParsedMessage $parsedMessage)
{
$message = new \Swift_Message();
if ($from = $parsedMessage->getFrom()) {
$message->setFrom($from);
}
// handle to with defaults
if ($to = $parsedMessage->getTo()) {
$message->setTo($to);
}
// handle cc with defaults
if ($cc = $parsedMessage->getCc()) {
$message->setCc($cc);
}
// handle bcc with defaults
if ($bcc = $parsedMessage->getBcc()) {
$message->setBcc($bcc);
}
// handle reply to with defaults
if ($replyTo = $parsedMessage->getReplyTo()) {
$message->setReplyTo($replyTo);
}
// handle subject with default
if ($subject = $parsedMessage->getSubject()) {
$message->setSubject($subject);
}
// handle body, no default values here
$message->setBody($parsedMessage->getMessageText());
if ($parsedMessage->getMessageHtml()) {
$message->addPart($parsedMessage->getMessageHtml(), 'text/html');
}
return $message;
}
示例5: send
/**
* Send an email to a number of recipients
* Returns the number of successful recipients, or FALSE on failure
* @param mixed The recipients to send to. One of string, array, 2-dimensional array or Swift_Address
* @param mixed The address to send from. string or Swift_Address
* @param string The message subject
* @param string The message body, optional
* @return int
*/
function send($recipients, $from, $subject, $body = null)
{
$this->addTo($recipients);
$sender = false;
if (is_string($from)) {
$sender = $this->stringToAddress($from);
} elseif (is_a($from, "Swift_Address")) {
$sender =& $from;
}
if (!$sender) {
return false;
}
$this->message->setSubject($subject);
if ($body) {
$this->message->setBody($body);
}
$sent = 0;
Swift_Errors::expect($e, "Swift_ConnectionException");
if (!$this->exactCopy && !$this->recipients->getCc() && !$this->recipients->getBcc()) {
$sent = $this->swift->batchSend($this->message, $this->recipients, $sender);
} else {
$sent = $this->swift->send($this->message, $this->recipients, $sender);
}
if (!$e) {
Swift_Errors::clear("Swift_ConnectionException");
if ($this->autoFlush) {
$this->flush();
}
return $sent;
}
$this->setError("Sending failed:<br />" . $e->getMessage());
return false;
}
示例6: testSend
public function testSend()
{
$message = new Swift_Message();
$message->setFrom('johnny5@example.com', 'Johnny #5');
$message->setSubject('Is alive!');
$message->addTo('you@example.com', 'A. Friend');
$message->addTo('you+two@example.com');
$message->addCc('another+1@example.com');
$message->addCc('another+2@example.com', 'Extra 2');
$message->addBcc('another+3@example.com');
$message->addBcc('another+4@example.com', 'Extra 4');
$message->addPart('<q>Help me Rhonda</q>', 'text/html');
$message->addPart('Doo-wah-ditty.', 'text/plain');
$attachment = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2 = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2->setDisposition('inline');
$message->attach($attachment);
$message->attach($attachment2);
$message->setPriority(1);
$headers = $message->getHeaders();
$headers->addTextHeader('X-PM-Tag', 'movie-quotes');
$messageId = $headers->get('Message-ID')->getId();
$transport = new PostmarkTransportStub('TESTING_SERVER');
$client = $this->getMock('GuzzleHttp\\Client', array('request'));
$transport->setHttpClient($client);
$o = PHP_OS;
$v = phpversion();
$client->expects($this->once())->method('request')->with($this->equalTo('POST'), $this->equalTo('https://api.postmarkapp.com/email'), $this->equalTo(['headers' => ['X-Postmark-Server-Token' => 'TESTING_SERVER', 'User-Agent' => "swiftmailer-postmark (PHP Version: {$v}, OS: {$o})", 'Content-Type' => 'application/json'], 'json' => ['From' => '"Johnny #5" <johnny5@example.com>', 'To' => '"A. Friend" <you@example.com>,you+two@example.com', 'Cc' => 'another+1@example.com,"Extra 2" <another+2@example.com>', 'Bcc' => 'another+3@example.com,"Extra 4" <another+4@example.com>', 'Subject' => 'Is alive!', 'Tag' => 'movie-quotes', 'TextBody' => 'Doo-wah-ditty.', 'HtmlBody' => '<q>Help me Rhonda</q>', 'Headers' => [['Name' => 'Message-ID', 'Value' => '<' . $messageId . '>'], ['Name' => 'X-PM-KeepID', 'Value' => 'true'], ['Name' => 'X-Priority', 'Value' => '1 (Highest)']], 'Attachments' => [['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt'], ['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt', 'ContentID' => 'cid:' . $attachment2->getId()]]]]));
$transport->send($message);
}
示例7: send
/**
* @param string $name
* @param array $context
* @param callable|null $callback a callback to modify the mail before it is sent.
*/
public function send($name, array $context = [], callable $callback = null)
{
$template = $this->twig->loadTemplate($name);
$blocks = [];
foreach (['from', 'from_name', 'to', 'to_name', 'subject', 'body_txt', 'body_html'] as $blockName) {
$rendered = $this->renderBlock($template, $blockName, $context);
if ($rendered) {
$blocks[$blockName] = $rendered;
}
}
$blocks = array_merge($context, $blocks);
$mail = new \Swift_Message();
$mail->setSubject($blocks['subject']);
$mail->setFrom(isset($blocks['from_name']) ? [$blocks['from'] => $blocks['from_name']] : $blocks['from']);
if (isset($blocks['to'])) {
$mail->setTo(isset($blocks['to_name']) ? [$blocks['to'] => $blocks['to_name']] : $blocks['to']);
}
if (isset($blocks['body_txt']) && isset($blocks['body_html'])) {
$mail->setBody($blocks['body_txt']);
$mail->addPart($blocks['body_html'], 'text/html');
} elseif (isset($blocks['body_txt'])) {
$mail->setBody($blocks['body_txt']);
} elseif (isset($blocks['body_html'])) {
$mail->setBody($blocks['body_html'], 'text/html');
}
if ($callback) {
$callback($mail);
}
$this->mailer->send($mail);
}
示例8: _swiftMail
protected function _swiftMail($to, $from, $subject, $message, $attachments = [], $html = true)
{
$mailer = $this->__getSwiftMailer($from);
if (is_array($to) && isset($to['email'])) {
if (isset($to['name'])) {
$to = [$to['email'] => $to['name']];
} else {
$to = $to['email'];
}
}
$mail = new \Swift_Message();
$mail->setSubject($subject)->setFrom($from['email'], $from['name'])->setTo($to);
if (isset($from['reply-to'])) {
if (is_array($from['reply-to']) && isset($from['email'])) {
$mail->setReplyTo($from['reply-to']['email'], $from['reply-to']['name']);
} else {
$mail->setReplyTo($from['reply-to']);
}
}
$mail->setBody($message, $html ? 'text/html' : 'text/plain');
foreach ($attachments as $attachment) {
$mail->attach(\Swift_Attachment::fromPath($attachment));
}
return $mailer->send($mail);
}
示例9: send
/**
* Send an email to a number of recipients
* Returns the number of successful recipients, or FALSE on failure
* @param mixed The recipients to send to. One of string, array, 2-dimensional array or Swift_Address
* @param mixed The address to send from. string or Swift_Address
* @param string The message subject
* @param string The message body, optional
* @return int
*/
public function send($recipients, $from, $subject, $body = null)
{
$this->addTo($recipients);
$sender = false;
if (is_string($from)) {
$sender = $this->stringToAddress($from);
} elseif ($from instanceof Swift_Address) {
$sender = $from;
}
if (!$sender) {
return false;
}
$this->message->setSubject($subject);
if ($body) {
$this->message->setBody($body);
}
try {
if (!$this->exactCopy && !$this->recipients->getCc() && !$this->recipients->getBcc()) {
$sent = $this->swift->batchSend($this->message, $this->recipients, $sender);
} else {
$sent = $this->swift->send($this->message, $this->recipients, $sender);
}
if ($this->autoFlush) {
$this->flush();
}
return $sent;
} catch (Swift_ConnectionException $e) {
$this->setError("Sending failed:<br />" . $e->getMessage());
return false;
}
}
示例10: fromWrappedMessage
/**
* @inheritDoc
*/
public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
{
if (!$wrappedMessage instanceof MailWrappedMessage) {
throw new MailWrapperSetupException('Not MailWrappedMessage');
}
$message = new \Swift_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()) {
$message->setBody($wrappedMessage->getContentHtml(), 'text/html');
}
return $message;
}
示例11: _setMessage
/**
* Создаём основу сообщения
*/
private function _setMessage()
{
if ((int) $this->_args['type'] === 0) {
$subj = 'АМТ банк: списание средств';
$body = "АМТ банк: Списание средств: {$this->_args['amount']};";
} else {
$subj = 'АМТ банк: внесение средств';
$body = "АМТ банк: Внесение средств: {$this->_args['amount']};";
}
$body .= " со счёта: {$this->_args['account']};\n";
if (isset($this->_args['payment'])) {
$body .= "на сумму: {$this->_args['payment']};\n";
}
$body .= "операция: {$this->_args['place']}; дата: " . $this->_args['timestamp'] . ";\n" . "доступный остаток: {$this->_args['balance']};";
$this->_message->setSubject($subj)->setFrom('card.statement@amtbank.com')->setTo('some.user@mail.easyfinance.ru')->setBody($body, 'text/plain');
}
示例12: sendInvitationEmail
private function sendInvitationEmail($subject, $name, $email, $body, $expert, $mailer)
{
$message = new Swift_Message();
$message->setFrom('Expert bank');
$message->setSubject($subject);
$message->setBody("U hebt via de expertbank een bericht ontvangen van {$name} ({$email}):\n\n{$body}");
$mailer->send($message, $expert->getEmail(), $email);
}
示例13: createEmail
/**
* @param \FTC\Bundle\AuthBundle\Entity\User $recipient
* @param string $subject
* @param string $body
*
* @return \Swift_Message
*/
protected function createEmail($recipient, $subject, $body)
{
$email = new \Swift_Message();
$email->addTo($recipient->getEmail(), $recipient->getFullname());
$email->setFrom('notifications@fixthatcode.com', 'FixThatCode.com');
$email->setSubject($subject);
$email->setBody($body, 'text/html');
return $email;
}
示例14: preparedMessage
private function preparedMessage($email, $parameters)
{
$message = new \Swift_Message();
$message->setTo($email);
$message->setFrom($this->template->renderBlock('from', $parameters), $this->template->renderBlock('from_name', $parameters));
$message->setSubject($this->template->renderBlock('subject', $parameters));
$message->setBody($this->template->renderBlock('body_text', $parameters));
$message->addPart($this->template->renderBlock('body_html', $parameters), 'text/html');
return $message;
}
示例15: createMessage
private function createMessage($body, $data, $config)
{
$message = new \Swift_Message();
$message->setFrom($config['from']['email']);
$message->setSubject($config['subject']);
$message->setBody($body);
$message->addTo($data->getEmail());
// $message->setSender($config['from']['name'])
return $message;
}