lundi 21 mars 2016

Laravel 5 send mail in contact form

I use Laravel 5.1 and want to send the admin of the page a mail with the content of a contact form.

In my .env file I added the following lines:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=admintest@gmail.com
MAIL_PASSWORD=adminpassword
MAIL_ENCRYPTION=tls

In my controller I have the following:

 Mail::send('Site::email', ['contactObject' => $contactObject], function ($message) use ($contactObject) {
        $message->from($contactObject->email, $contactObject->vorname)->subject('New contact!');

        $message->to('admintest@gmail.com');
    });

$contactObject == contains the form which was filled out in the form from the user

Desired result: When admintest@gmail.com receive a email, the sender of the mail should be $contactObject->email

Actual result: When admintest@gmail.com receive a email, the sender of the mail is admintest@gmail.com

Any ideas what goes wrong? Thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire