本文整理汇总了PHP中Illuminate\Mail\Message::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::attach方法的具体用法?PHP Message::attach怎么用?PHP Message::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Mail\Message
的用法示例。
在下文中一共展示了Message::attach方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAttachments
public function testGetAttachments()
{
$getAttachment = \Closure::bind(function ($message) {
return $this->getAttachments($message);
}, $this->transport, SendgridV3Transport::class);
$message = new Message($this->getMessage());
$file = __DIR__ . '/test.png';
$message->attach($file);
$res = $getAttachment($message->getSwiftMessage());
$this->assertEquals(base64_encode(file_get_contents($file)), array_get($res, '0.content'));
$this->assertEquals('test.png', array_get($res, '0.filename'));
}
示例2: 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;
}
示例3: 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']]);
}
}
示例4: buildAttachments
/**
* Add all of the attachments to the message.
*
* @param \Illuminate\Mail\Message $message
* @return $this
*/
protected function buildAttachments($message)
{
foreach ($this->attachments as $attachment) {
$message->attach($attachment['file'], $attachment['options']);
}
foreach ($this->rawAttachments as $attachment) {
$message->attachData($attachment['data'], $attachment['name'], $attachment['options']);
}
return $this;
}
示例5: addAttachments
/**
* Add the attachments to the message.
*
* @param \Illuminate\Mail\Message $mailMessage
* @param \Illuminate\Notifications\Messages\MailMessage $message
* @return void
*/
protected function addAttachments($mailMessage, $message)
{
foreach ($message->attachments as $attachment) {
$mailMessage->attach($attachment['file'], $attachment['options']);
}
foreach ($message->rawAttachments as $attachment) {
$mailMessage->attachData($attachment['data'], $attachment['name'], $attachment['options']);
}
}
示例6: testSetAttachment
public function testSetAttachment()
{
$setAttachment = \Closure::bind(function (&$data, $message) {
return $this->setAttachment($data, $message);
}, $this->transport, 'Sichikawa\\LaravelSendgridDriver\\Transport\\SendGridTransport');
$data = [];
$message = new Message($this->getMessage());
$message->attach(__DIR__ . '/test.png');
$setAttachment($data, $message->getSwiftMessage());
$this->assertEquals('stream', get_resource_type($data['files[test.png]']));
}