Support the ongoing development of Laravel.io →
posted 10 years ago
Mail

I have implemented contact form in my laravel project using 'smtp.gmail.com' host. I have used this tutorial to build contact form: http://dixitpatel.com/form-in-laravel-with-email-function/ My problem is that when I receive mail the 'from' and 'to' field has same email that I have set into 'to' field instead of form posted email for 'from' field.

My code is here:

Mail::send('emails.hello', $data, function($message) use ($data) { $message->from($data['email'] , $data['first_name']);
$message->to('mymail@gmail.com', 'Amy')->subject('Contact Request'); });

Here $data is input form filed array.

Last updated 2 years ago.
0

try inside of app/config/mail.php

/*
	|--------------------------------------------------------------------------
	| Global "From" Address
	|--------------------------------------------------------------------------
	|
	| You may wish for all e-mails sent by your application to be sent from
	| the same address. Here, you may specify a name and address that is
	| used globally for all e-mails that are sent by your application.
	|
	*/

	'from' => array('address' => 'application@whatever.com', 'name' => '<Name of Sender >'),
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jaimin107 jaimin107 Joined 1 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.