I am trying to send a contact us mail with attachment, when I submit the form, it just comeback with no errors but mail never sent. see my code
I setup my config/mail like this
'driver' => 'mail',
'host' => 'smtp.hotmail.com',
'port' => 587,
'from' => array('[email protected]' => null, 'name' => null),
'encryption' => 'tls',
'username' => null,
'password' => null,
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
Controller
public function getJoinRequest()
{
$data = Input::all();
$rules = array(
'name' => 'required|regex:/^[\pL\s\-]+$/u',
'email' => 'required|email',
'job' => 'required|alpha',
'comment' => 'required|min:25'
);
$validator = Validator::make($data, $rules);
if ($validator->passes()) {
Mail::send('emails.joinRetunMessage.hello', $data, function ($message) use ($data) {
$message->from($data['email'], $data['name']);
$message->to('[email protected]', 'El Arabia')->subject('Join us request');
$message->attach($data['resume']->getRealPath(), array(
'as' => 'resume.' . $data['resume']->getClientOriginalExtension(),
'mime' => $data['resume']->getMimeType())
);
});
return Redirect::to('/join-us')
->with('message', 'Your message has been sent. Thank You!');
} else {
return Redirect::to('/join-us')->withErrors($validator);
}
}
here is how I got it to work with my hotmail
'driver' => 'mail',
'host' => 'hotmail.com',
'port' => 587,
'from' => array('address' => '[email protected]', 'name' => 'ElArabia'),
'encryption' => 'tls',
'username' => "[email protected]",
'password' => "XXXX",
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
and same with my domain information. but the the thing I have to say about this is you can write your 'username' => "[email protected]", and then say send it to the same email this will never work.