public static function sendSESFromHtml($html, $to, $subject) { $tos = array(); if (!empty($to)) { $array = explode(";", $to); if (!empty($array) && sizeof($array) > 0) { foreach ($array as $mail) { if (!empty($mail)) { array_push($tos, $mail); } else { error_log($mail . " not valid"); } } } } if (!empty($tos) && sizeof($tos) > 0) { $ses = new SimpleEmailService(AWS_SES_API_KEY, AWS_SES_API_SECRET); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->setSubjectCharset("UTF-8"); $m->setMessageCharset("UTF-8"); foreach ($tos as $mail) { $m->addTo($mail); } $m->setFrom(AWS_SES_API_FROM); $m->setSubject($subject); $m->setMessageFromString(null, $html); return $ses->sendEmail($m); } else { error_log(LanguageUtils::getText("LANG_UTILS_MAIL_ERROR_EMAIL_EMPTY")); } return false; }
public function sendEmail() { $email = str_replace('INTRODUCEE_NAME', $this->introducee->getName(), str_replace('OTHER_NAME', $this->other->getName(), str_replace('INTRODUCER_NAME', $this->userName, str_replace('LINK', $this->introductionUrl . '', Content::getInstance()->getEmail('email-introduction'))))); $subject = str_replace('INTRODUCEE_NAME', $this->introducee->getName(), str_replace('INTRODUCER_NAME', $this->userName, Content::c()->introduce->email)); // Send the email with AWS SES $ses = new SimpleEmailService(SES_KEY, SES_SECRET); $ses->enableVerifyHost(false); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->addTo($this->introducee->getEmail()); $m->setFrom(SES_FROM); $m->setSubject($subject); $m->setMessageFromString($subject . ' ' . $this->introductionUrl, $email); $result = $ses->sendEmail($m); if (!$result) { return false; } // Save the email result to the database $sth = $this->db->prepare('INSERT INTO aws_ses (recipient_id, ses_message_id, ses_request_id, introduction_id) VALUES (:recipient_id, :ses_message_id, :ses_request_id, :introduction_id)'); $sth->execute(array(':recipient_id' => $this->introducee->getId(), ':ses_message_id' => $result['MessageId'], ':ses_request_id' => $result['RequestId'], ':introduction_id' => $this->introductionId)); return true; }
public function paymentProcess() { if ($_SERVER['REQUEST_METHOD'] == "POST") { $id = $_POST['custom']; list($aid, $cid) = explode('-', $id); $affinfo = $this->ClientModel->getAffiliatePaymentInfo($aid); // Check Number 1 ------------------------------------------------------------------------------------------------------------ $receiver_email = $_POST['receiver_email']; if ($receiver_email == $affinfo->affiliate_paypal_account) { $payment_amount = $_POST['mc_gross']; if ($payment_amount == $affinfo->affiliate_client_reg_charge) { // Check number 2 ------------------------------------------------------------------------------------------------------------ if ($_POST['payment_status'] == "Completed") { // Handle how you think you should if a payment is not complete yet, a few scenarios can cause a transaction to be incomplete // incs('config/dbcon.php'); // assign posted variables to local variables $pstatus = $_POST['payment_status']; $pamount = $_POST['mc_gross']; $txn_id = $_POST['txn_id']; $payer_email = $_POST['payer_email']; $id = $_POST['custom']; list($aid, $cid) = explode('-', $id); $paytitle = $_POST['item_name1']; $updatepayment = $this->ClientModel->paypalPaymentInsert($aid, $cid, $paytitle, $pamount, $payer_email, $txn_id, $pstatus); // if ($updatepayment!='') { $subject = 'Client Registration Payment'; // header part of email template $msg = '<html> <head> <meta charset="utf-8"> <title>Email Template</title> </head> <body> <div class="box" style="padding:0px;width:40%; margin:0 auto;-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:1px solid #ccc;"> <div class="title" style="-webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; background:#ccc; color:#fff;"> <h3 style="padding:10px; margin:0px; color:#ac6f00;"><img src="' . base_url() . 'frontend/images/logo.png" height="35px" style="vertical-align:middle;margin-right:15px;">The Credit University</h3> </div> <div class="content" style="padding:10px; font-size:14px;"><p style="font-size:13px;">'; $msg .= 'Payment Successfully completed. Please login <a href="' . base_url() . 'admin"> Click Here</a>'; // footer part of email template $msg .= '</p></div> <div class="footer" style="-webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;background:#ccc; color:#ac6f00; margin:0px; padding:1px 10px;"> </div> </div> </body> </html>'; $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); //print_r($ses->verifyEmailAddress('*****@*****.**')); $m = new SimpleEmailServiceMessage(); $m->addTo('contact <' . $updatepayment->email . '>'); $m->setFrom('The Credit University' . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $message = $msg; $m->setMessageFromString('', $message); $ses->sendEmail($m); // } } //payment_status check } } } else { $subject = 'Fail CPN referrer Partner Registration Payment'; $msg = '<html> <head> <meta charset="utf-8"> <title>Email Template</title> </head> <body> <div class="box" style="padding:0px;width:40%; margin:0 auto;-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:1px solid #ccc;"> <div class="title" style="-webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; background:#ccc; color:#fff;"> <h3 style="padding:10px; margin:0px; color:#ac6f00;"><img src="' . base_url() . 'frontend/images/logo.png" height="35px" style="vertical-align:middle;margin-right:15px;">The Credit University</h3> </div> <div class="content" style="padding:10px; font-size:14px;"><p style="font-size:13px;">'; $msg .= 'Payment Failed.'; // footer part of email template $msg .= '</p></div> <div class="footer" style="-webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;background:#ccc; color:#ac6f00; margin:0px; padding:1px 10px;"> </div> </div> </body> </html>'; $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); //print_r($ses->verifyEmailAddress('*****@*****.**')); $m = new SimpleEmailServiceMessage(); $m->addTo('contact <*****@*****.**>'); $m->setFrom('The Credit University' . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $message = $msg; $m->setMessageFromString('', $message); $ses->sendEmail($m); } }
public function quickConnect() { $this->load->library('form_validation'); $this->load->model('UserModel'); $this->load->model('EmailModel'); $name = $this->input->post('name'); $email = $this->input->post('email'); $subject = 'Quick Connect'; $adminUsers = $this->UserModel->getAdminUsers(); foreach ($adminUsers as $userAdmin) { $receiverAdminId[] = $userAdmin->id; $receiverAdminEmail[] = $userAdmin->email; } $emailId = $this->EmailModel->insertEmails('Success', $receiverAdminId); $link = '<a href="' . base_url(ADMIN_PATH . "mail/read_mail/" . $emailId) . '" target="_blank">here</a>'; $emailMessage = "You've received email from " . $name . ". Click " . $link . " to view the message."; $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->addTo('*****@*****.**'); $m->setFrom($email . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $message = $emailMessage; $m->setMessageFromString('', $message); if ($ses->sendEmail($m)) { if ($this->uri->segment(1) == 'Contact' || $this->uri->segment(1) == 'contact') { $this->session->set_flashdata("su_message", "Email Sent Successfully"); redirect("home"); } else { echo "<script>alert('Email Sent Successfully');window.history.back();</script>"; } } }
function sendEmailsToClient($email, $line_detail) { $site_link = '<a href="' . base_url('member') . '" target="_blank">here</a>'; $emailMessage = "You hav been added to your card by owner for verify. " . $line_detail . ' ' . ' Click' . ' .' . $site_link . " to login "; $msg = $emailMessage; $subject = "Added to the Card For Verify"; $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->addTo($email); $m->setFrom($email_sender . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $message = $msg; $m->setMessageFromString('', $message); $ses->sendEmail($m); $this->session->set_flashdata("su_message", "Email Sent Successfully..."); }
function supportEmail() { $clientOwner = array('Client', 'Owner'); $result = array_intersect($clientOwner, $this->session->userdata(ROLES)); if ($result) { $brokerId = $this->UserModel->getBrokerFromClientid($this->session->userdata(USER_ID)); $brokerIdArray = array($brokerId); $brokerEmail[] = $this->UserModel->getEmailAddress($brokerId); } $adminUsers = $this->UserModel->getAdminUsers(); foreach ($adminUsers as $userAdmin) { $receiverAdminId[] = $userAdmin->id; $receiverAdminEmail[] = $userAdmin->email; } if ($brokerIdArray) { $receiverId = array_unique(array_merge($receiverAdminId, $brokerIdArray)); $receiverEmail = array_unique(array_merge($receiverAdminEmail, $brokerEmail)); } else { $receiverId = $receiverAdminId; $receiverEmail = $receiverAdminEmail; } $emailId = $this->EmailModel->insertEmails('Success', $receiverId); $link = '<a href="' . base_url(ADMIN_PATH . "mail/read_mail/" . $emailId) . '" target="_blank">here</a>'; $emailMessage = "You've received email from " . $this->session->userdata(NAME) . ". Click " . $link . " to view the message."; $subject = $this->input->post('subject'); $message = $emailMessage; $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->addTo(EMAILSENDER); $m->addCC($receiverEmail); $m->setFrom($this->name . ' via Credit University' . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $msg = $message; $m->setMessageFromString('', $msg); $ses->sendEmail($m); $this->session->set_flashdata("supportMessage", "Support & Suggestion email has been sent successfully."); redirect(ADMIN_PATH); }
function resetPassword() { $code = $this->autoGenerateCode(); $email_to = $this->input->post('email'); $answer_1 = $this->input->post('answer1'); $answer_2 = $this->input->post('answer2'); $result = $this->UserModel->checkQuestionsAnswers($email_to, $answer_1, $answer_2); $id = $this->UserModel->checkEmailId($email_to); if (!empty($id) && !empty($result)) { $this->UserModel->updateProfile(null, $id, $code); $subject = "Forgot Password"; $message = "Click on the following link to reset your password"; $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $from = '*****@*****.**'; $m->addTo($email_to); $m->setFrom($from . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $msg = $message; $msg .= '<br/><a href="' . base_url() . 'member/changePassword' . '/' . $code . '">CLICK HERE</a>'; $m->setMessageFromString('', $msg); $ses->sendEmail($m); $this->session->set_flashdata('message', "<b style=\"color:green; alignment:center;\" >Please refer to your email. The reset link has been send to your email successfully.</b>"); redirect(base_url() . 'member/forgotpassword'); } else { $this->session->set_flashdata('message', "<b style=\"color:red;\">Contact Broker For Difficulties</b>"); redirect(base_url() . 'member/forgotpassword'); } }
public function sendEmails($emails, $subject, $templateId, $userId, $full_name = '', $other = '') { $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $simpleEmailServiceMessage = new SimpleEmailServiceMessage(); if (!empty($emails)) { $simpleEmailServiceMessage->addTo($emails); } else { $simpleEmailServiceMessage->addTo($other); } $simpleEmailServiceMessage->setFrom('The Credit University' . '<' . EMAILSENDER . '>'); $simpleEmailServiceMessage->setSubject($subject); if (empty($other)) { $code = $this->getInterpretedNewsLetterTemplate($templateId, $full_name, $userId, $this->NewsLetterModel->getCampaignId($templateId), $other = ''); } else { $code = $this->getInterpretedNewsLetterTemplate($templateId, $full_name = '', $userId, $this->NewsLetterModel->getCampaignId($templateId), $other); } $simpleEmailServiceMessage->setMessageFromString('', $code); $sent = $ses->sendEmail($simpleEmailServiceMessage); return $sent; }
function sendEmails() { $user_id = $this->session->userdata(USER_ID); $user_role_details = $this->RoleModel->getRolesByUserId($user_id); $email_sender_type = $user_role_details->value; $user_details = $this->UserModel->getUser($user_id); $email_sender = $user_details->first_name . ' ' . $user_details->middle_initial . ' ' . $user_details->last_name; $subject = $this->input->post('subject'); $to_emails = $this->input->post('toemails[]'); $msg = $this->input->post('msg'); $name = $this->UserModel->getNameFromEmail($to_emails); $role_name = $this->UserModel->getRoleFromEmail($to_emails); $user_ids = $this->UserModel->getUserIdFromEmail($to_emails); $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->addTo($to_emails); $m->setFrom($email_sender . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $msg = '<html> <head> <meta charset="utf-8"> <title>Email Template</title> </head> <body> <div class="box" style="padding:0px;width:40%; margin:0 auto;-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:1px solid #ccc;"> <div class="title" style="-webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; background:#ccc; color:#fff;"> <h3 style="padding:10px; margin:0px; color:#ac6f00;"><img src="' . base_url() . 'frontend/images/logo.png" height="35px" style="vertical-align:middle;margin-right:15px;">The Credit University</h3> </div> <div class="content" style="padding:10px; font-size:14px;"><p style="font-size:13px;">'; $msg .= 'Dear User,<br/>'; $msg .= $this->input->post('msg'); $msg .= '<br/><br/>'; $msg .= 'Yours Sincerely,<br/>'; $msg .= $email_sender; $msg .= 'Americancpn <br/>'; // footer part of email template $msg .= '</p></div> <div class="footer" style="-webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;background:#ccc; color:#ac6f00; margin:0px; padding:1px 10px;"> <p>Yours Sincerely,<br> The Credit University Team</p> </div> </div> </body> </html>'; $message = $msg; $m->setMessageFromString('', $message); if ($ses->sendEmail($m)) { $this->EmailModel->insertEmails('Success', $email_sender, $email_sender_type, $name, $role_name, $user_ids); redirect(ADMIN_PATH . "user/mailbox"); } else { redirect(ADMIN_PATH . "user/compose"); } }
function sendWelcomeRegistrationMail($register, $broker_id = "", $token = '', $userId = '') { $this->load->model('UserModel'); $this->load->model('NewsLetterModel'); $this->load->model('RoleModel'); $this->load->library('parser'); if ($register == "") { return false; } $user_details = $this->UserModel->getUserByEmail($register); $role_details = $this->RoleModel->getRoleWithEmail($register); $register_role = $role_details->label; $register_name = $user_details->first_name . ' ' . $user_details->middle_initial . ' ' . $user_details->last_name; $subject = 'Welcome to The Credit University'; if ($broker_id) { $user = $this->UserModel->getUserByUserId($broker_id); $broker = $user->first_name . ' ' . $user->middle_initial . ' ' . $user->last_name; } $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $simpleEmailServiceMessage = new SimpleEmailServiceMessage(); $sent = ""; if (!empty($user->email)) { $simpleEmailServiceMessage->addTo($user->email); $simpleEmailServiceMessage->setFrom('The Credit University' . '<' . EMAILSENDER . '>'); $simpleEmailServiceMessage->setSubject($subject); $today = date('Y-m-d'); $data1 = array('subject' => 'Registered to The Credit University', 'date' => $today, 'registered' => $register, 'register_name' => $register_name, 'role' => $register_role, 'under_registered' => $broker); $code = $this->NewsLetterModel->getWelcomeLetterByShortCode(BROKER_WELCOME_TEMPLATE); if ($code != "") { $code = $this->parseTemplate($code, $data1); $simpleEmailServiceMessage->setMessageFromString('', $code); $sent = $ses->sendEmail($simpleEmailServiceMessage); } } $simpleEmailServiceMessage->addTo($register); $simpleEmailServiceMessage->setFrom('The Credit University' . '<' . EMAILSENDER . '>'); $simpleEmailServiceMessage->setSubject($subject); $today = date('Y-m-d'); $data = array('subject' => 'Registered to The Credit University', 'register_name' => $register_name, 'date' => $today, 'registered' => $register, 'role' => $register_role, 'under_registered' => $broker, 'token' => $token, 'user_id' => $userId); $code_register = $this->NewsLetterModel->getWelcomeLetterByShortCode(WELCOME_TEMPLATE); if ($code_register != "") { $code_register = $this->parseTemplate($code_register, $data); $simpleEmailServiceMessage->setMessageFromString('', $code_register); $sent = $ses->sendEmail($simpleEmailServiceMessage); } return $sent; }
function sendEmails($email, $link) { $emailMessage = "You've received email from " . $this->session->userdata(NAME) . ". Click " . $link . " to view the message."; $receiverUserInfo = $this->UserModel->getUserByEmail($email); $receiverName = $receiverUserInfo->first_name . ' ' . $receiverUserInfo->middle_initial . ' ' . $receiverUserInfo->last_name; $user_id = $this->session->userdata(USER_ID); $user_details = $this->UserModel->getUser($user_id); $email_sender = $user_details->first_name . ' ' . $user_details->middle_initial . ' ' . $user_details->last_name; $msg = $emailMessage; $subject = $this->input->post('subject'); $this->load->library('SimpleEmailService'); $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ'); $ses->enableVerifyPeer(false); $m = new SimpleEmailServiceMessage(); $m->addTo($email); $m->setFrom($email_sender . '<' . EMAILSENDER . '>'); $m->setSubject($subject); $data = array('receiver' => $receiverName, 'emailer' => $email_sender, 'message' => $msg); $code = $this->parser->parse('administrator/mailed_template', $data); $m->setMessageFromString('', $code); $ses->sendEmail($m); $this->session->set_flashdata("su_message", "Email Sent Successfully..."); redirect(ADMIN_PATH . "mail/compose"); }