mardi 31 mai 2016

Why isn't my "from" working sending email in Laravel?

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
MAIL_USERNAME=chris@listingnaples.com
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('chris@listingnaples.com')
            ->replyTo($data['email'], $data['name']);
});

}

A dd($data) shows:

array:6 [▼
  "_token" => "ZSvuhAhkCetDFZOrQMtbDHBy2RfzECGFT03wixt3"
  "MLSNumber" => "216003681"
  "name" => "John Doe"
  "email" => "jdoe@gmail.com"
  "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 chris@listingnaples.com!

My mail config file even has:

'from' => ['address' => null, 'name' => null],



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire