I'm trying to send a very basic email in Laravel but the from field is not working. Instead of it being from the sender with their return address, it has MY return address and their name.
My .env has
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypass;
MAIL_ENCRYPTION=tls
My controller has:
public function sendEmail(ShowingPageContactRequest $request) {
// email me custom email
$data = $request->all();
Mail::send('emails.propertyemail', $data, function ($message) use ($data) {
$message->subject('Property Query from ' . $data['name'])
->sender($data['email'], $data['name'])
->from($data['email'], $data['name'])
->to('[email protected]')
->replyTo($data['email'], $data['name']);
});
}
A dd($data) shows:
array:6 [▼
"_token" => "ZSvuhAhkCetDFZOrQMtbDHBy2RfzECGFT03wixt3"
"MLSNumber" => "216003681"
"name" => "John Doe"
"email" => "[email protected]"
"phone" => "(239) 555-1212"
"comments" => "This is my comment or question."
]
So the email is there and John Doe is there. However, when I check my email it says it is from John Doe but [email protected]!
My mail config file even has:
'from' => ['address' => null, 'name' => null],