Hello everyone,
I hope I can find a solution for my problem in here. I'm trying to send an email using laravel to multiple addresses. when I do, I get the success message, however the email is not received by any user. I even put an if statement around the mail to save a fail message in an array and display it later, no email failed, all are sent. But the recipient never received the email. The website is hosted in hostgator, and I'm using their mail service. Here is my mail.php code
return array(
'driver' => 'mail',
'host' => '',
'port' => '',
'from' => array(),
'encryption' => '',
'username' => '',
'password' => '',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
Here is the code that sends the email
$subject = Input::get('subject');
$message = Input::get('message');
$members = User::get(array('email'));
$user = Sentry::getUser();
foreach($members as $member)
{
Mail::send('emails.emailTemp', array('subject'=>$subject, 'body'=>$message), function($message) use($member, $subject, $user)
{
$message->from($user->email, $user->first_name.' '.$user->last_name);
$message->to($member->email)->subject($subject);
if(Input::file('attachment'))
{
$message->attach(Input::file('attachment')->getRealPath(), array('as' => Input::file('attachment')->getClientOriginalName(), Input::file('attachment')->getMimeType()));
}
});
}
return Redirect::back()->with('success','Email was sent successfully');
Thank you
The Mail driver only works when you have hosted your project on a live server, if you already have, mail won't be sent automatically most times because your host service provider may have disabled your service from sending emails, i had this problem recently, just call your host service provider and let them know that you want to be able to send ail with your app/website.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community