Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 795

How to Add Headers using Mail faced of Laravel 10

$
0
0

I' am using the below code set the smtp configuration first and then I'm trying to send the mail where I need to set some headers as well. But I am unable todo. Please see my codes and help me to reach my goals. Here is my code.

$stmp = ['mail.mailers' => ['user_stmp' => ['transport' => 'smtp','host' => $sender_info->smtp_host_name,'port' => $sender_info->smtp_port,'encryption' => $sender_info->smtp_port == '465' ? 'ssl' : 'tls','username' => $sender_info->smtp_user_name,'password' => $sender_info->smtp_password,'from' =>            [                //FIXME TWO BOTTOM LINES MUST BE GIVEN A DO OVER PROBABLY'address' => $sender_email,'name' => $sender_name,            ],    ]]];config()->set($stmp);Mail::mailer('user_stmp')->send('emails.reply', ['from' => $sender_email,'body' => $request->body,], function ($m) use ($sender_email, $sender_name, $request,$reply) {    $m->from($sender_email, $sender_name);    $m->to($request->to_mail)->subject($request->subject);    if ($request->cc)    {        $m->cc($request->cc);    }    if ($request->bcc)    {        $m->bcc($request->bcc);    }    /*$m->getHeaders()        ->addTextHeader('Message-ID', $reply->message_id)        ->addTextHeader('In-Reply-To', $reply->in_reply_to)        ->addTextHeader('References', $reply->refs);*/    $m->withSwiftMessage(function ($message) use ($reply) {        $headers = $message->getHeaders();        $headers->addTextHeader('Message-ID', $reply->message_id);        $headers->addTextHeader('In-Reply-To', $reply->in_reply_to);        $headers->addTextHeader('References', $reply->refs);    });});

Right now I'm getting the below error

"Call to undefined method Illuminate\\Mail\\Message::withSwiftMessage()"

Viewing all articles
Browse latest Browse all 795

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>