I am creating some booking system and have HTML form in which user enter his email (and other stuff). I would like to get email as if user has send it from his email address, but my Gmail always shows that I have sent it (i.e. sender email address is same as 'username' from app/config/mail.php = [email protected]).
This is Send::mail() method I am using
Mail::send('reservation-email', ['data' => $data], function($message) use ($data) {
$message->from($data['email'], $data['name']);
$message->to('[email protected]', 'ABC')->subject($data['subject']);
});
This is my app/config/mail.php
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => null, 'name' => null),
'encryption' => 'tls',
'username' => '[email protected]',
'password' => 'XYZ_password',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I found out that I could use replyTo
Mail::send('reservation-email', ['data' => $data], function($message) use ($data) {
$message->from($data['email'], $data['name']);
$message->to('[email protected]', 'ABC')->subject($data['subject']);
$message->replyTo($data['email'], $data['name']); // <--------------------
});
but then I do not know what is the purpose of 'from' field?
Thank you in advance!
from
is used when defining and address and name to new message.replyTo
is used when defining an address and name to the previous message. – gokhanakkurt