Example #1
7
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $event = DB::table('orders')->join('users', 'users.email', '=', 'orders.custID')->select('users.*', 'orders.DueDate AS chkDate', 'orders.ordID AS id', 'orders.ordDate', 'DueDate AS chkDate', 'orders.status AS status')->get();
     foreach ($event as $eve) {
         //Get orders which have passed the dealine and are ongoing and orders which are closing the deadline.
         if (Carbon::today()->addDays(2)->eq(Carbon::parse($eve->chkDate)) or Carbon::today()->addDays(1)->eq(Carbon::parse($eve->chkDate)) or Carbon::today()->eq(Carbon::parse($eve->chkDate))) {
             $dDateArr[]['dLineIDs'] = $eve->id;
         } elseif (Carbon::today()->subDay()->gte(Carbon::parse($eve->chkDate)) and $eve->status == 'Ongoing') {
             $dDateArr[]['passIDs'] = $eve->id;
         }
     }
     $msg = '<h3>The following orders need your attention:- </h3><ul>';
     foreach ($dDateArr as $dets) {
         if (isset($dets['dLineIDs'])) {
             $msg .= '<li>The Order ID' . $dets['dLineIDs'] . 'is reaching the deadline.</li>';
         }
         if (isset($dets['passIDs'])) {
             $msg .= '<li>The Order ID' . $dets['passIDs'] . ' has passed the deadline.</li>';
         }
     }
     $msg .= '</ul>';
     if (isset($dDateArr)) {
         Mail::send(array(), array(), function ($message) use($msg) {
             $message->from('*****@*****.**', 'Admin System');
             $message->to('*****@*****.**');
             $message->subject('Urgent:Alert');
             $message->setBody($msg, 'text/html');
         });
         if (count(Mail::failures()) == 0) {
             echo 'Artist has been successfully alerted at ' . Carbon::now();
         }
     }
 }
Example #2
4
 public function send(Collection $data)
 {
     $validator = $this->validator($data->toArray(), $this->type);
     if (!$validator->fails()) {
         Mailer::send("emails.{$this->type}", $data->toArray(), function ($message) use($data) {
             $fromAddress = $data->get('from_address');
             $fromName = $data->get('from_name');
             $toAddress = $data->get('to_address');
             $toName = $data->get('to_name');
             $cc = $data->get('cc[]', []);
             $bcc = $data->get('bcc[]', []);
             // Send the message
             $message->from($fromAddress, $fromName);
             $message->to($toAddress, $toName)->subject($data->get('subject'));
             foreach ($cc as $address) {
                 $message->cc($address, null);
             }
             foreach ($bcc as $address) {
                 $message->bcc($address, null);
             }
         });
     } else {
         // Validation failed
         return ['success' => 0, 'status' => "Failed to validate message", 'messages' => $validator->getMessageBag()->all(), 'data' => $data, 'type' => $this->type];
     }
     if (!count(Mailer::failures())) {
         $this->sent_at = Carbon::now();
         Log::info("Sent {$this->type} email");
         return ['success' => 1, 'status' => "successfully sent message", 'data' => $data, 'type' => $this->type];
     }
     Log::info("Failed to send {$this->type} email");
     return ['success' => 0, 'status' => "failed to send message", 'messages' => "failed to send message", 'data' => $data, 'type' => $this->type];
 }
 /**
  * @param $user
  * @return bool
  * @throws GeneralException
  */
 public function sendConfirmationEmail($user)
 {
     //$user can be user instance or id
     if (!$user instanceof User) {
         $user = $this->find($user);
     }
     Mail::send('frontend.auth.emails.confirm', ['token' => $user->confirmation_code], function ($message) use($user) {
         $message->to($user->email, $user->name)->subject(app_name() . ': ' . trans('exceptions.frontend.auth.confirmation.confirm'));
     });
     if (count(Mail::failures()) > 0) {
         throw new GeneralException("There was a problem sending the confirmation e-mail");
     }
     return true;
 }
 public function sendMail()
 {
     $dets = array('msg' => Request::input('mailDets'), 'subject' => Request::input('subjectH'), 'to' => Request::input('toH'), 'file' => Request::file('file'));
     $rules = array('msg' => 'required', 'subject' => 'required', 'to' => 'required|email');
     $messages = array('msg.required' => 'The email body is required', 'to.required' => 'The recipient\'s address is required', 'to.email' => 'The recepient address is not of the correct format');
     $validator = Validator::make($dets, $rules, $messages);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         //Get the details from the form and send it as an array to the function.
         try {
             Mail::send(array(), array(), function ($message) use($dets) {
                 $message->from('*****@*****.**', 'PaintBuddy Team');
                 $message->to($dets['to']);
                 $message->subject($dets['subject']);
                 $message->setBody($dets['msg'], 'text/html');
                 if (isset($dets['file'])) {
                     $message->attach(Request::file('file'), ['as' => Request::file('file')->getClientOriginalName(), 'mime' => Request::file('file')->getClientOriginalExtension()]);
                 }
             });
         } catch (\Exception $e) {
             throw new SendMailException($e->getMessage());
         }
         if (count(Mail::failures()) > 0) {
             return Redirect::back()->withInput()->withErrors('Mail was not sucessfully sent. Please try again');
         } else {
             return Redirect::back()->with('success', true)->with('message', 'Mail sucessfully sent');
         }
     }
 }
Example #5
0
 public static function sendTemplate($path, $params, $locale = null)
 {
     if (!isset($params[self::EMAIL_FROM])) {
         $params[self::EMAIL_FROM] = appEmail();
     }
     if (!isset($params[self::EMAIL_FROM_NAME])) {
         $params[self::EMAIL_FROM_NAME] = appName();
     }
     if (!isset($params[self::EMAIL_SUBJECT])) {
         $params[self::EMAIL_SUBJECT] = trans('label.message_from_') . appName();
     }
     if (!isset($params[self::EMAIL_TO])) {
         return false;
     }
     if (!empty($locale)) {
         $params['site_locale'] = $locale;
     }
     $locale = $params['site_locale'];
     try {
         Mail::send('emails.' . $path . '.' . $locale, $params, function ($message) use($params) {
             $message->from($params[MailHelper::EMAIL_FROM], $params[MailHelper::EMAIL_FROM_NAME]);
             $message->subject($params[MailHelper::EMAIL_SUBJECT]);
             if (isset($params[MailHelper::EMAIL_TO_NAME])) {
                 $message->to($params[MailHelper::EMAIL_TO]);
             } else {
                 $message->to($params[MailHelper::EMAIL_TO], $params[MailHelper::EMAIL_TO_NAME]);
             }
         });
         return count(Mail::failures()) > 0;
     } catch (\Exception $ex) {
         return false;
     }
 }
Example #6
0
 protected function sendMail($input)
 {
     $data = ['user' => Auth::user(), 'title' => Lang::get('c::support.subject')] + $input;
     if (!Config::get('c::support-email')) {
         throw new \RuntimeException('Cannot send support e-mail - c::support-email config value is empty');
     }
     Mail::send('c::support.mail', $data, function ($msg) {
         $msg->to(Config::get('c::support-email'))->subject(Lang::get('c::support.subject'));
     });
     return count(Mail::failures()) == 0;
 }
Example #7
0
 /**
  * Sends an email
  *
  * @param string $template Template name
  * @param array $data Email data. Must contain
  * @example
  * [
  *  'mail_to' => <recipient email address>,
  *  'recipient_name' => <recipient_name>,
  *  'mail_from' => <sender_address>,
  *  'sender_name' => <sender_name>,
  *  'subject' => <email_subject>
  * ]
  * @return bool
  */
 public function sendMail($template, array $data)
 {
     Mail::send($template, $data, function ($msg) use($data) {
         $msg->to($data['mail_to'], $data['recipient_name']);
         $msg->from($data['mail_from'], $data['sender_name']);
         $msg->replyTo($data['mail_from'], $data['sender_name']);
         $msg->subject($data['subject']);
     });
     // Check for email failures
     if (count(Mail::failures()) > 0) {
         return false;
     }
     return true;
 }
Example #8
0
 protected function mailer($confirmation_url, $email_to, $name_to)
 {
     $this->confirmation_params['confirmation_url'] = $confirmation_url;
     $this->email_to = $email_to;
     $this->name_to = $name_to;
     Mail::send($this->views, $this->confirmation_params, function ($message) {
         $message->subject($this->subject);
         $message->from($this->email_from, $this->name_from);
         $message->to($this->email_to, $this->name_to);
     });
     if (count(Mail::failures()) > 0) {
         return false;
     }
     return true;
 }
 /**
  * Function to send emails to the user and to the admin.
  * The input array must be in the following format
  * [
  *  'user_email' => '',
  *  'username' => '',
  *  'user_subject' => '',
  *  'admin_subject' => '',
  *  'user_email_text' => '',
  *  'admin_mail_text' =>
  * ]
  *
  * @param Array $data Data to use for the emails
  * @param string $user_template User email template
  * @param string $admin_template Admin email template
  * @return boolean
  */
 protected function sendMail($data, $user_template, $admin_template)
 {
     // Send user email
     Mail::send($user_template, $data, function ($msg) use($data) {
         $msg->to($data['user_email'], $data['username']);
         $msg->from(Config::get('mail.from.address'), Config::get('mail.from.name'));
         $msg->subject($data['user_subject']);
     });
     // Check for email failures
     if (count(Mail::failures()) > 0) {
         return false;
     }
     // Send admin email
     Mail::send($admin_template, $data, function ($msg) use($data) {
         $msg->to(Config::get('mail.from.address'), Config::get('mail.from.name'));
         $msg->from($data['user_email'], $data['username']);
         $msg->subject($data['admin_subject']);
     });
     // Check for email failures
     if (count(Mail::failures()) > 0) {
         return false;
     }
     return true;
 }
Example #10
0
 /**
  * Reply feedback to sender via email.
  *
  * @param $id
  * @param $name
  * @param $email
  * @param $message
  * @param $reply
  * @return bool
  */
 public function reply($id, $name, $email, $message, $reply)
 {
     $data = ['name' => $name, 'feedback' => $message, 'reply' => $reply];
     Mail::send('emails.admin.feedback', $data, function ($message) use($id, $name, $email) {
         $message->from('*****@*****.**', 'Infogue.id');
         $message->replyTo('*****@*****.**', 'Infogue.id');
         $message->to($email)->subject('Reply feedback ticket #' . $id);
     });
     return Mail::failures();
 }
Example #11
0
 /**
  * @param              $rp_id
  * @param array        $data
  * @param array|string $profiles
  *
  * @return bool
  */
 public function send($rp_id, array $data = [], $profiles = [])
 {
     $this->setSender();
     $this->setReceivers($profiles);
     $this->emailsByProduct($rp_id);
     $user = $this->user;
     $data['rp_id'] = $rp_id;
     $this->setHtml($data);
     Mail::send('emails.layout', ['html' => $this->html], function ($message) use($user) {
         $message->from($this->sender['email'], $this->sender['name']);
         $message->subject($this->sender['name'] . '. ' . $this->subject);
         foreach ($this->customEmails as $customEmail) {
             $message->to($customEmail);
         }
         foreach ($this->receivers as $key => $receiver) {
             $message->to($receiver['email'], $receiver['name']);
         }
         foreach ($this->emails as $email) {
             $message->cc($email->email, $email->name);
         }
     });
     if (count(Mail::failures()) > 0) {
         // dd(Mail::failures);
         return false;
     }
     return true;
 }