In laravel cron i have a function like given below :
public function booking_mail()
{
$data_to_mail= DB::table('tbl_booking as book')
->select('book.id as book_id','book.*','twd.id as wk_id','twd.*')
->join('tbl_workers_details as twd', 'twd.id', '=', 'book.worker_id')
->where('book.status','=','0')
->get();
$data['viewpage']='mailtemplates.booking';
$data['toemail']=$agent[0]->email;
$data['listing_no']=$data_to_mail[0]->listing_no;
$data['cv_no']=$data_to_mail[0]->cv_no;
$mail= Mail::send($data['viewpage'], ['userdata'=>$data], function ($message)
use ($data) {
$message->to($data['toemail'],'Booking Mail')->subject('Inquiry Mail For Booking');
if($data['attach']!=''){
$message->attach($data['attach']);
}
});
if($data['attach']!=''){
unlink($data_to_mail[0]->civil_id_copy);
}
$result=DB::table('tbl_booking')
->where('id','=',$data_to_mail[0]->book_id)
->update(array(
'status'=>'1',
));
}
This function is working fine but when i added one for mail function at the end of the function its not working returning me the error. i dont know why this happening to me. i want to do this because i want to send the mail for two different user with two different data and view code is given below which is returning me the error.
public function booking_mail()
{
$data_to_mail= DB::table('tbl_booking as book')
->select('book.id as book_id','book.*','twd.id as wk_id','twd.*')
->join('tbl_workers_details as twd', 'twd.id', '=', 'book.worker_id')
->where('book.status','=','0')
->get();
$data['user_viewpage']='mailtemplates.enduser_booking';
$data['toemail']=$agent[0]->email;
$data['listing_no']=$data_to_mail[0]->listing_no;
$data['cv_no']=$data_to_mail[0]->cv_no;
//send e-mail to the agent for booking
$mail= Mail::send($data['viewpage'], ['userdata'=>$data], function ($message)
use ($data) {
$message->to($data['toemail'],'Booking Mail')->subject('Inquiry Mail For Booking');
if($data['attach']!=''){
$message->attach($data['attach']);
}
});
$mail= Mail::send($data['user_viewpage'], ['userdata'=>$data], function ($message)
use ($data) {
$message->to($data['toemail'],'Booking Mail')->subject('Confirmation mail');
});
$result=DB::table('tbl_booking')
->where('id','=',$data_to_mail[0]->book_id)
->update(array(
'status'=>'1',
));
}
why this is happening its returning me the error like:
Swift_TransportException in StreamBuffer.php line 268: Connection could not be established with host mail.XXXX.com [Connection timed out #110]
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire