I have to send an email in my application. Now i am testing the sending of mail. Inside app/mailer i have two classes: Mailer and ContactMailer
But is not working. I am getting this error: Laravel 4: Class 'Mailer\ContactMailer' not found. I try to run composer dump-autoload but is not helping. I don't know what i can do. The class is not recognized.
This is the code:
1.Mailer class:
<? namespace Mailers;
abstract class Mailer
{
protected $to;
protected $email;
protected $subjet;
protected $view;
protected $data = [];
}
public function __construct()
{
}
public function deliver()
{
return \Mail::send($this->view, $this->data, function($message)
{
$message->to($this->email, $this->to)->subject($this->subject);
});
}
2.ContactMailer class:
<?php namespace Mailers;
class ContactMailer extends Mailer
{
public function suggest()
{
$this->to = 'Asoyaracuy';
$this->email = 'cardozo.anibal@gmail.com';
$this->subjet = 'Queja o Sujerencia';
$this->view = 'emails.contact.suggest';
return $this;
}
}
And this is the route:
Route::post('sendsuggest','HomeController@sendsuggest');
Of course here is the sendSuggest action
public function sendSuggest()
{
$subject = Input::get('title');
$body = Input::get('body');
$mailer = new Mailer\ContactMailer;
$mailer->suggest()->deliver();
return 'Enviado';
}
And Composer.json:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/mailers"
]
},
Someone can help me please?