/** * 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; }
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']]); } }
/** * 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); } }
/** * Adds the recipients to the message * * @param \Illuminate\Mail\Message $message * @return void **/ protected function addRecipients(Message $message) { if ($overwriteTo = $this->getOverwriteTo()) { $message->to($overwriteTo); return; } $first = true; foreach ($this->recipients as $recipient) { if ($first) { $message->to($recipient); } else { $message->bcc($recipient); } $first = false; } }
/** * Build the invoice notification message. * * @param \Illuminate\Mail\Message $message * @param mixed $billable * @param \Laravel\Cashier\Invoice * @param array $invoiceData * @return void */ protected function buildInvoiceMessage($message, $billable, $invoice, array $invoiceData) { $message->to($billable->email, $billable->name)->subject($invoiceData['product'] . ' Invoice')->attachData($invoice->pdf($invoiceData), 'invoice.pdf'); }
public function testToMethodWithOverride() { $this->swift->expects($this->once())->method('setTo')->with('*****@*****.**', 'Foo'); $this->assertInstanceOf(Message::class, $this->message->to('*****@*****.**', 'Foo', true)); }
/** * 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; }