laravel mailmessage

raw

code.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
 
namespace App\Notifications;
 
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
 
class VerifyEmail extends Notification implements ShouldQueue
{
    /**
     * Build the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return MailMessage
     */
    public function toMail($notifiable)
    {
        \App\Components\ClientAdapter::getInstance()
            ->setNameFromNameInDb($this->client_name)
            ->apply();
 
        $this->verificationUrl = $this->verificationUrl($this->user_id, $this->user_email);
 
        if (static::$toMailCallback) {
            return call_user_func(static::$toMailCallback, $notifiable, $this->verificationUrl);
        }
 
        $client_name = $this->client_name;
        return (new MailMessage)
            ->withSwiftMessage([$this, 'addCustomHeaders'])
            //this is unfortunately necessary because the Mailer has already
            // been instantiated and already has the previous settings
            ->from(config('mail.from.address'), config('mail.from.name'))
 
            ->subject(__("emails.{$client_name}.email-verification.subject"))
            ->greeting(__("emails.{$client_name}.email-verification.greeting"))
            ->line(__("emails.{$client_name}.email-verification.line_1"))
            ->action(__("emails.{$client_name}.email-verification.action_label"), $this->verificationUrl)
            ->line(__("emails.{$client_name}.email-verification.line_2"))
            ->line(__("emails.{$client_name}.email-verification.line_3"))
            ->salutation(__("emails.{$client_name}.email-verification.salutation"));
    }
    /**
     * Add our own headers to the e-mail
     */
    public function addCustomHeaders(\Swift_Message $message)
    {
        $message->getHeaders()->addTextHeader('Auto-Submitted', 'auto-generated');
    }
}
 
raw

phork0.txt

"laravel" mailmessage "Auto-Submitted"
3834 Recommendations for Automatic Responses to Electronic Mail
Christian Weiske Christian Weiske
owner

History