mardi 24 novembre 2015

How to change header information of mail in Laravel?

I am creating a simple contact us form using Laravel 5.1

public function sendMessage(){
    $data = [
        'name' => Input::get('name'),
        'email' => Input::get('email'),
        'subject' => Input::get('subject'),
        'body' => Input::get('body')
    ];
    Mail::send('emails.contact',$data, function($message) use($data){
        $message->from($data['email'], $data['name']);
        $message->to('smartrahat@gmail.com','Mohammed');
        $message->subject($data['subject']);
    });
    Session::flash('success_message','Mail sent successfully!');
    return redirect('contact');
}

Everything is working fine but the sender email address is not the one it get from the contact page. The email is sent from the address which I configure in .env

I want to have the email from the sender email address which he filled up contact form. Or, you can say I want to change the header information (only from, I can change other information).



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire