configuration of mail.php
<?php
return array(
'driver' => 'smtp',
'host' => 'smtp.mandrillapp.com',
'port' => 587,
'from' => array('address' => 'akram1rekik@gmail.com', 'name' => 'Akram Rekik'),
'encryption' => 'tls',
'username' => 'akram1rekik@gmail.com',
'password' => 'key api',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
and this is my controller
public function postForm()
{
$regles = array(
'nom' => 'required|min:5|max:20|alpha',
'email' => 'required|email',
'texte' => 'required|max:250'
);
$validation = Validator::make(Input::all(), $regles);
if ($validation->fails()) {
return Redirect::to('contact/form')->withErrors($validation)->withInput();
} else {
Mail::send('emails.contact', $Input::all(), function($message) {
$message->to('akram1rekik@gmail.com', 'Akram Rekik')->subject('Welcome to the Laravel 4 Auth App!');
});
return View::make('confirm');
}
}
when I send the form of contact, I get "Error in exception handler".
I need help :)
Could you make a screenshot of the error? Only thing I see is $Input::all() as second parameter in Mail::send() but I think that's just a typo on this post. Actually you are just using smtp instead of the mandrill driver, which is ok but I just wanted to point it out. You could try to put the Mail::send() between comments to see if the exception is still thrown.
for use mandrill best package is :
doxxon/laravel-mandrill-request
for example :
public function send($fromEmail = NULL,$toEmail,$type,$code = NULL)
{
$fromEmail = $fromEmail ? $fromEmail : Settings::get('sender_email');
$payload =
[
'message' =>
[
'subject' => Lang::get("email.$type"),
'html' => (string)View::make("email::$type",['code' => $code]),
'from_email' => $fromEmail,
'to' => [['email' => $toEmail]]
]
];
$response = Mandrill::request('messages/send', $payload);
return $response;
}
You don't have to set the driver to mandrill. You can send with smtp via Mandrill.
Have you checked out the sairiz/mandrill package?
This is a Laravel package from Mandrill itself. View the docs here.
This is a L4 package.
hansvn said:
Have you checked out the sairiz/mandrill package?
This is a Laravel package from Mandrill itself. View the docs here.
Please RTFM: http://laravel.com/docs/5.0/mail
To use the Mandrill driver, set the driver option to mandrill in your config/mail.php configuration file. Next, create an config/services.php configuration file if one does not already exist for your project. Verify that it contains the following options:
'mandrill' => [ 'secret' => 'your-mandrill-key', ],
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community