public function sendEmail($template, $data = [], $to, $toName, $subject, $cc = null, $bcc = null, $replyTo = null)
 {
     $result = false;
     try {
         $config = new Config();
         $messageHeader = ['from' => $config->getValueByKey('address_sender_mail'), 'fromName' => $config->getValueByKey('display_name_send_mail'), 'to' => $to, 'toName' => $toName, 'cc' => $cc, 'bcc' => $bcc, 'replyTo' => $replyTo, 'subject' => $subject];
         \Mail::send($template, $data, function ($message) use($messageHeader) {
             $message->from($messageHeader['from'], $messageHeader['fromName']);
             $message->to($messageHeader['to'], $messageHeader['toName']);
             if (!is_null($messageHeader['cc'])) {
                 $message->cc($messageHeader['cc']);
             }
             if (!is_null($messageHeader['bcc'])) {
                 $message->bcc($messageHeader['bcc']);
             }
             if (!is_null($messageHeader['replyTo'])) {
                 $message->replyTo($messageHeader['replyTo']);
             }
             $message->subject($messageHeader['subject']);
         });
         $result = true;
     } catch (Exception $e) {
         $result = ['success' => false, 'message' => $e->getMessage()];
     }
     return \Response::json($result);
 }
 public function send(Mail $mail)
 {
     $data = collect(request()->json()->all());
     $result = $mail->send($data);
     $mail->fill($data->toArray())->save();
     return $result;
 }
Exemple #3
0
 public static function sendComfirmationMail($user)
 {
     $json = json_encode(["email" => $user->email, "confirmation_code" => $user->confirmation_code]);
     $data = base64_encode($json);
     \Mail::send('emails.confirmation', ['data' => $data], function ($message) use($user) {
         $message->from('*****@*****.**', "Polls");
         $message->to($user->email)->subject('Email confirmation');
     });
 }
Exemple #4
0
 /**
  * http://laravel.com/docs/4.2/mail
  */
 public function sendWelcomeEmail()
 {
     # Create an array of data, which will be passed/available in the view
     $data = array('user' => Auth::user());
     Mail::send('emails.welcome', $data, function ($message) {
         $recipient_email = $this->email;
         $recipient_name = $this->first_name . ' ' . $this->last_name;
         $subject = 'Welcome ' . $this->first_name . '!';
         $message->to($recipient_email, $recipient_name)->subject($subject);
     });
 }
Exemple #5
0
 public function sendVerificationEmail($data, $confirmation_code)
 {
     try {
         $to_view = array('confirmation_code' => $confirmation_code);
         $sending = email::send('emails.confirm', $to_view, function ($message) use($data) {
             $message->from($data['email'], 'Web Mail Directive')->to($data['email'])->subject('Your Reminder');
         });
     } catch (Exception $e) {
         $sending = $e->getMessage();
     }
     return $sending;
 }
 public function email_admin_proposal_deposit()
 {
     $subject = 'New Proposal Deposit';
     $data = array('proposal' => $this, 'from' => NOTIFICATION_EMAIL, 'from_name' => NOTIFICATION_NAME, 'to' => REVIEW_EMAIL, 'fname' => REVIEW_NAME, 'subject' => $subject);
     Mail::send('emails.proposals/admin_proposal_deposit', $data, function ($message) use($data) {
         $message->to($data['to'], $data['fname'])->subject($data['subject']);
         $message->from($data['from'], $data['from_name']);
     });
     return TRUE;
 }
Exemple #7
0
 public function reopen_buyer()
 {
     $subject = $this->user->fname . ', your project has been active.';
     $email_view = 'emails.jobs/project_reopened';
     $data = array('job' => $this, 'job_url' => $this->plink(), 'from' => NOTIFICATION_EMAIL, 'from_name' => NOTIFICATION_NAME, 'to' => '*****@*****.**', 'fname' => $this->user->fname, 'sender_name' => NOTIFICATION_NAME, 'subject' => $subject);
     Mail::send($email_view, $data, function ($message) use($data) {
         $message->to($data['to'], $data['fname'])->subject($data['subject']);
         $message->from($data['from'], $data['from_name']);
     });
     return TRUE;
 }
Exemple #8
0
 public static function resetPassword($email)
 {
     $user = User::where('email', $email)->first();
     if (!isset($user)) {
         return Redirect::to('/crm/login')->withMessage('user account not exist, please try again.');
     }
     // reset user password
     $random_pwd = str_random(10);
     $user->password = Hash::make($random_pwd);
     $user->save();
     //send the link to the new user password to user.
     Mail::send('emails.forgot_password', ['password' => $random_pwd], function ($message) use($user) {
         $message->to($user->email, $user->name)->subject('Forgot Password');
     });
     //
     return Redirect::to('/crm/login')->withMessage('Password reset instruction has been sent to the registered email address.');
 }
 public function email_seller_service_purchase()
 {
     $data = array('workstream' => $this, 'from' => NOTIFICATION_EMAIL, 'from_name' => NOTIFICATION_NAME, 'to' => $this->seller->email, 'fname' => $this->seller->fname, 'sender_name' => NOTIFICATION_NAME, 'subject' => $this->seller->fname . ' you have received an order for your service. ID: #' . $this->proposal->id);
     Mail::send('emails.workstream/seller_service_purchase', $data, function ($message) use($data) {
         $message->to($data['to'], $data['fname'])->subject($data['subject']);
         $message->from($data['from'], $data['from_name']);
     });
     return TRUE;
 }