mardi 4 août 2015

Laravel mail not sending

I'm trying to send an email to the website admin, but it isn't working as expected. I did this before, where the exact same code is working.. I'm using my gmail account to send emails with my Laravel application.

So my setup is as follows

'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'postmaster@test.com', 'name' => 'Postmaster'),
'encryption' => 'tls',
'username' => 'xxx@gmail.com',
'password' => 'xxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,

The next thing I do is fill in a (test) form

{{ Form::open(array('id'=>'mail-form', 'url'=>'en/mail', 'method' => 'post')) }}
{{ Form::text('first_name', null , array('placeholder'=>Lang::get('quotation.first_name'), 'class'=>'text-input')) }}
{{ Form::text('name', null , array('placeholder'=>Lang::get('quotation.name'), 'class'=>'text-input')) }}
{{ Form::text('email', null , array('placeholder'=>Lang::get('quotation.email'), 'class'=>'text-input')) }}
{{ Form::submit(Lang::get('quotation.send'), array('class'=>'submit-mail')) }}
{{ Form::close() }}

This gets processed in my HomeController

public function postMail(){
    $input = Input::all();

    $data = array(
        'first_name' => $input['first_name'],
        'name' => $input['name'],
        'email' => $input['email'],
    );

    Mail::send('_emails.quotation', $data, function($message){
        $message->to($input['email'], $input['name'].' '.$input['first_name'])->subject('Test');
    });

    return Redirect::back();
}

When I submit the form I get a 302 found HTTP code, which then directly redirects me to the homepage..

Aucun commentaire:

Enregistrer un commentaire