The mail configuration file is app/config/mail.php, and contains options allowing you to change your SMTP host, port, and credentials, as well as the from address. If you wish to use the PHP mail function or sendmail you may change the driver in the configuration file.
'driver' => 'smtp',
'host' => 'mail.example.com',
'port' => 587,
'from' => array('address' => 'mail@example.com', 'name' => 'My Website'),
'encryption' => 'tls',
'username' => 'mail@example.com',
'password' => 'mail-password',
If you don't have an e-mail on your server you can even use a Gmail account.
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'your-gmail-address@gmail.com', 'name' => 'My Website'),
'encryption' => 'tls',
'username' => 'your-gmail-address@gmail.com',
'password' => 'your-gmail-password',
There Mailgun, Mandrill and SparkPost api drivers require PHP >= 5.4.
Copy your Mailgun API Key and Domain to app/config/services.php under the mailgun section:
'mailgun' => array(
'secret' => 'your-mailgun-key',
'domain' => 'your-mailgun-domain'
),
Copy your Mandrill API Key to app/config/services.php under the mandrill section:
'mandrill' => array(
'secret' => 'your-mandrill-key',
),
Copy your SparkPost API Key to app/config/services.php under the sparkpost section:
'sparkpost' => array(
'secret' => 'your-sparkpost-key',
),
The e-mail templates are stored in app/views/emails/. These are used when sending the activation e-mail, the password reminder, etc.
If you want to send your custom e-mails you can use Mail::send method:
$data = array('body' => 'Welcome to My Website!');
Mail::send('emails.welcome', $data, function($message) {
$message->to('foo@example.com', 'John Doe');
$message->subject('Welcome!');
});
The first argument passed to the send method is the name of the view (app/views/emails/welcome.php) that should be used as the e-mail body. The second is the $data that should be passed to the view, and the third is a Closure allowing you to specify various options on the e-mail message.
For all the methods available on the $message instance please see src/Hazzard/Mail/Message.php.