A
A
AlpineMilk2018-08-13 19:56:12
Laravel
AlpineMilk, 2018-08-13 19:56:12

Why doesn't the sender change when sending a letter?

I am making feedback on the site. The letter is sent, but the sender is always written as the one I have in MAIL_USERNAME, regardless of what is in $message->from(). How to change the sender? What am I doing wrong?

$mailTemplate = View::make('mails.feedback', [
            'data' => $request->all()
        ]);

         Mail::raw($mailTemplate, function($message) {
            $message->from('[email protected]');
            $message->to('[email protected]');
            $message->setContentType('text/html');
            $message->subject('Письмо с блога');
        });

The template has the simplest text. Settings in .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=мой емаил
MAIL_PASSWORD=мой пароль
MAIL_ENCRYPTION=tls

I tried to create a class and inherit from Mailable, but the result is the same.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2018-08-13
@ky0

And you thought Google would let you send through their servers from the left addresses? If you want to substitute - set up SPF on your domain and send from any name.

H
Heyhihello, 2018-08-14
@Heyhihello

You can set up mail for a domain and send from various email boxes [email protected] . If you are interested in mail.ru: https://biz.mail.ru/mail/
You can also use Yandex.PDD , just keep in mind that in this case MAIL_USERNAMEit will have to match with $message->from()for successful sending of letters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question