1

EDIT: i'm testing it on a live Ubuntu 14 LTS Server

I'm working on a Laravel Project which needs to send emails. First I tried the native PHP on how to send email like:

<?php
   // the message
   $msg = "First line of text\nSecond line of text";

  // use wordwrap() if lines are longer than 70 characters
  $msg = wordwrap($msg,70);

 // send email
 mail("someone@example.com","My subject",$msg);
?>

But his thing doesn't work. Laravel is not giving me error either so what I did is use Laravel's default email configuration. I already configured the parameters in the mail.php I'm using our company email settings provided by rackspace then I do this

$test = Mail::send('emails.message', ['user' => $user], function ($m) use ($user) {
        $m->to('sample@email.com', $user->name)->subject('Custtomer Order Accepted !');
   });

The sample@email.com is just example in my code. I'm using a legit email for that. Then when I tried to var_dump test I get int(0) which I think a failed response? How do I use it correctly? Or even just the simple mail function is not working? I have the view already in emails.message

jackhammer013
  • 2,295
  • 11
  • 45
  • 95

2 Answers2

0

Check your email settings, and after this, check spam folder too.
http://php.net/manual/en/mail.configuration.php

0

In laravel 5.1 check the bellow mail setting

.env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=<your email>
MAIL_PASSWORD=<password>
MAIL_ENCRYPTION=tls

mail.php file

return [
'driver' => env('MAIL_DRIVER', 'mail'),
'host' => env('MAIL_HOST', 'localhost'),
'port' => env('MAIL_PORT', ""),
'from' => ['address' => "<from email>", 'name' => "<name>"],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME',""),
'password' => env('MAIL_PASSWORD',""),
];
Mitul Koradiya
  • 318
  • 2
  • 5
  • 19