本文整理汇总了PHP中Illuminate\Mail\Message::from方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::from方法的具体用法?PHP Message::from怎么用?PHP Message::from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Mail\Message
的用法示例。
在下文中一共展示了Message::from方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMessage
protected function createMessage()
{
$message = new Message(new Swift_Message());
// If a global from address has been specified we will set it on every message
// instances so the developer does not have to repeat themselves every time
// they create a new message. We will just go ahead and push the address.
if (isset($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
return $message;
}
示例2: testMultipleSend
public function testMultipleSend()
{
$message = new Message($this->getMessage());
$message->from('from@example.com', 'test_from')->to('foo@example.com', 'foo');
$res = $this->transport->send($message->getSwiftMessage());
$this->assertEquals(200, $res->getStatusCode());
$message = new Message($this->getMessage());
$message->from('from@example.com', 'test_from')->to('bar@example.com', 'bar');
$res = $this->transport->send($message->getSwiftMessage());
$this->assertEquals(200, $res->getStatusCode());
}
示例3: getIlluminateEmails
/**
* Builds the email array and return it as an array of all emails to be sent!!
*/
public function getIlluminateEmails()
{
$emails = [];
foreach ($this->tos as $destination) {
$mail = new Message(new Swift_Message());
$mail->to($destination[0], $destination[1]);
$mail->from($this->from['email'], $this->from['name']);
$mail->subject($this->subject);
$mail->setBody($this->body['content'], $this->body['type']);
foreach ($this->files as $file) {
$mail->attach($file);
}
$emails[] = $mail;
}
return $emails;
}
示例4: sendClosure
protected function sendClosure(Message $mailObject)
{
$mailObject->subject($this->subject);
$mailObject->from($this->from[0]['address'], $this->from[0]['name']);
foreach ($this->to as $toDetails) {
$mailObject->to($toDetails['address'], $toDetails['name']);
}
foreach ($this->cc as $ccDetails) {
$mailObject->cc($ccDetails['address'], $ccDetails['name']);
}
foreach ($this->bcc as $bccDetails) {
$mailObject->bcc($bccDetails['address'], $bccDetails['name']);
}
foreach ($this->attachments as $attachmentDetails) {
$mailObject->attach($attachmentDetails['file'], ['as' => $attachmentDetails['filename'], 'mime' => $attachmentDetails['mimetype']]);
}
}
示例5: createMessage
/**
* Create a new message instance.
*
* @return \Illuminate\Mail\Message
*/
protected function createMessage()
{
// Get the DKIM selector.
$selector = Config::get('mail.dkim.selector');
// If we have a DKIM selector, then add the signing.
if (!empty($selector)) {
// Use the signed message with support for signing.
// So long as there is a selector we will do this, even if a private
// key is not set. This is handy if the application wants to add its
// own signatures later.
$message = new Message(new Swift_SignedMessage());
// Get the key and domain name.
// Ideally these would be specific to the selector, with the selector being
// chosen according to the domain of the sending address. At this stage we do
// not know what the final sending addressis going to be.
$private_key = Config::get('mail.dkim.private_key');
$domain_name = Config::get('mail.dkim.domain_name');
if (!empty($private_key) && !empty($domain_name)) {
// Do the DKIM signing.
$dkim_signer = new Swift_Signers_DKIMSigner($private_key, $domain_name, $selector);
// Issue #1: ignore certain headers that cause end-to-end failure.
$dkim_signer->ignoreHeader('Return-Path');
$dkim_signer->ignoreHeader('Bcc');
$dkim_signer->ignoreHeader('DKIM-Signature');
$dkim_signer->ignoreHeader('Received');
$dkim_signer->ignoreHeader('Comments');
$dkim_signer->ignoreHeader('Keywords');
$dkim_signer->ignoreHeader('Resent-Bcc');
$message->attachSigner($dkim_signer);
}
} else {
// Non-signed message.
$message = new Message(new Swift_Message());
}
// If a global from address has been specified we will set it on every message
// instances so the developer does not have to repeat themselves every time
// they create a new message. We will just go ahead and push the address.
if (isset($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
return $message;
}
示例6: buildFrom
/**
* Add the sender to the message.
*
* @param \Illuminate\Mail\Message $message
* @return $this
*/
protected function buildFrom($message)
{
if (!empty($this->from)) {
$message->from($this->from[0]['address'], $this->from[0]['name']);
}
return $this;
}
示例7: addressMessage
/**
* Address the mail message.
*
* @param \Illuminate\Mail\Message $mailMessage
* @param mixed $notifiable
* @param \Illuminate\Notifications\Messages\MailMessage $message
* @return void
*/
protected function addressMessage($mailMessage, $notifiable, $message)
{
$recipients = empty($message->to) ? $notifiable->routeNotificationFor('mail') : $message->to;
if (!empty($message->from)) {
$mailMessage->from($message->from[0], isset($message->from[1]) ? $message->from[1] : null);
}
if (is_array($recipients)) {
$mailMessage->bcc($recipients);
} else {
$mailMessage->to($recipients);
}
if ($message->cc) {
$mailMessage->cc($message->cc);
}
if (!empty($message->replyTo)) {
$mailMessage->replyTo($message->replyTo[0], isset($message->replyTo[1]) ? $message->replyTo[1] : null);
}
}
示例8: testFromMethod
public function testFromMethod()
{
$this->swift->expects($this->once())->method('setFrom')->with('foo@bar.baz', 'Foo');
$this->assertInstanceOf(Message::class, $this->message->from('foo@bar.baz', 'Foo'));
}
示例9: generateMessage
/**
* Generates a \Illuminate\Mail\Message template ready to send
*
* @param array $args = []
* @return $this
*/
public function generateMessage($args = [])
{
if (!empty($args)) {
foreach ($args as $att => $v) {
if (array_key_exists($att, get_object_vars($this))) {
$this->{$att} = $v;
}
}
}
$msg = new Message(new \Swift_Message());
if ($this->hasFrom()) {
$from = $this->getFrom();
$msg->from($from[0], $from[1]);
}
if ($this->hasSender()) {
$sender = $this->getSender();
$msg->sender($sender[0], $sender[1]);
}
if ($this->hasTo()) {
$to = $this->getTo();
$msg->to($to[0], $to[1]);
}
if ($this->hasCc()) {
$cc = $this->getCc();
$msg->cc($cc[0], $cc[1]);
}
if ($this->hasBcc()) {
$bcc = $this->getBcc();
$msg->bcc($bcc[0], $bcc[1]);
}
if ($this->hasReplyTo()) {
$reply_to = $this->getReplyTo();
$msg->replyTo($reply_to[0], $reply_to[1]);
}
if ($this->hasSubject()) {
$msg->subject($this->getSubject());
}
if ($this->hasAttach()) {
foreach ($this->getAttach() as $attach) {
$msg->attachData($attach[0], $attach[1], $attach[2]);
}
}
if ($this->hasPriority()) {
$msg->priority($this->getPriority());
}
$this->setMessage($msg);
return $this;
}