Email send is working but using a query to get the user's email value, the email send does not work and no error is showing also this is what I've tried
This is working:
use PHPMailer\PHPMailer;
use Mail;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class userController extends Controller
{
public function user_send_email_caller(Request $request)
{
$username = session()->get('username');
Mail::send('mail', array('name'=> $username), function($message) {
$message
->from('email@example.com', 'test')
->to('email@example.com', 'name')
->subject('subject');
});
}
}
This one with query doesn't work
use PHPMailer\PHPMailer;
use Mail;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class userController extends Controller
{
public function user_send_email_caller(Request $request)
{
$email = DB::table('sample_table')->select('user_email')->where('id_user','=',
'1')->get();
Mail::send('mail', array('name'=> $email), function($message) {
$message
->from('email@example.com', 'test')
->to('email@example.com', 'name')
->subject('subject');
});
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire