Exemplo n.º 1
0
 /**
  * send
  *
  * @param ResetPassword $resetPassword
  * @param User $user
  * @param array $mailConfig
  *
  * @return mixed
  */
 public function sendRestPasswordEmail(ResetPassword $resetPassword, User $user, $mailConfig)
 {
     $toEmail = $user->getEmail();
     $fromEmail = $mailConfig['fromEmail'];
     $fromName = $mailConfig['fromName'];
     $subject = $mailConfig['subject'];
     $bodyTemplate = $mailConfig['body'];
     //Ignore blank emails
     if (!trim($toEmail)) {
         return;
     }
     $vars = ['name' => '', 'userId' => $user->getId(), 'url' => 'https://' . $_SERVER['HTTP_HOST'] . '/reset-password?fromPasswordResetEmail=1&id=' . $resetPassword->getResetId() . '&key=' . $resetPassword->getHashKey()];
     foreach ($vars as $name => $value) {
         $bodyTemplate = str_replace('__' . $name . '__', $value, $bodyTemplate);
         // Handle BC
         $bodyTemplate = str_replace('{' . $name . '}', $value, $bodyTemplate);
     }
     try {
         $html = new MimePart($bodyTemplate);
         $html->type = "text/html";
         $body = new MimeMessage();
         $body->setParts([$html]);
         $message = new Message();
         $message->setBody($body)->setFrom($fromEmail, $fromName)->setSubject($subject);
         foreach (explode(',', $toEmail) as $email) {
             $message->addTo(trim($email));
         }
         $transport = new \Zend\Mail\Transport\Sendmail();
         $transport->send($message);
     } catch (InvalidArgumentException $e) {
         // nothing
     }
 }
Exemplo n.º 2
0
 public function index02Action()
 {
     $message = new \Zend\Mail\Message();
     $message->setBody('This is the text of the email.');
     $message->setFrom('*****@*****.**', 'Sender\'s name');
     $message->addTo('*****@*****.**', 'Name of recipient');
     $message->setSubject('TestSubject');
     $transport = new \Zend\Mail\Transport\Sendmail();
     $transport->send($message);
 }
Exemplo n.º 3
0
 public function send($params)
 {
     list($recipient, $sender, $issue) = $params;
     $mail = new \Zend\Mail\Message();
     $mail->setBody($issue['rule']);
     $mail->setFrom('*****@*****.**', 'OnTheGo Notifier');
     $mail->addTo($recipient);
     $mail->setSubject('Issue report on Zend Server');
     $transport = new \Zend\Mail\Transport\Sendmail();
     $transport->send($mail);
 }
Exemplo n.º 4
0
 private function sendMail($messageBody, $subject)
 {
     $message = new \Zend\Mail\Message();
     $message->setEncoding('utf-8');
     $message->setBody($messageBody);
     $message->addTo('*****@*****.**');
     $message->setSubject($subject);
     $message->setFrom('*****@*****.**');
     $transport = new \Zend\Mail\Transport\Sendmail();
     if (APPLICATION_ENV == 'production') {
         $transport->send($message);
     }
     return true;
 }
Exemplo n.º 5
0
Arquivo: Mail.php Projeto: visapi/amun
    public function send($name, $email, array $values = array())
    {
        if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
            // no valid email provided
            return;
        }
        $sql = <<<SQL
SELECT
\t`mail`.`from`,
\t`mail`.`subject`,
\t`mail`.`text`,
\t`mail`.`html`,
\t`mail`.`values`
FROM 
\t{$this->registry['table.mail']} `mail`
WHERE 
\t`mail`.`name` = ?
SQL;
        $row = $this->sql->getRow($sql, array($name));
        if (!empty($row)) {
            // check values
            $neededValues = array();
            if (!empty($row['values'])) {
                $neededValues = explode(';', $row['values']);
            }
            if (count(array_diff(array_keys($values), $neededValues)) > 0) {
                throw new Exception('Missing values in ' . $name);
            }
            // send mail
            $mail = new \Zend\Mail\Message();
            $mail->setBody($this->substituteVars($row['text'], $values));
            $mail->setFrom($row['from']);
            $mail->addTo($email);
            $mail->setSubject($this->substituteVars($row['subject'], $values));
            $transport = new \Zend\Mail\Transport\Sendmail();
            $transport->send($mail);
        } else {
            throw new Exception('Invalid mail template');
        }
    }
 /**
  * Prepare header string from message
  *
  * @param  Message $message
  * @return string
  */
 protected function prepareHeaders(Zend\Mail\Message $message)
 {
     $originalSubject = '';
     $headers = $message->getHeaders();
     if ($headers->has('Subject')) {
         $subjectHeader = $headers->get('Subject');
         $originalSubject = $subjectHeader->getFieldValue();
     }
     $body = $message->getBody();
     if ($body instanceof Zend\Mime\Message) {
         $parts = $body->getParts();
         foreach ($parts as $part) {
             /* @var $part Zend\Mime\Part */
             if ($part->getType() == Zend\Mime\Mime::TYPE_HTML) {
                 $part->setContent("******** PGP/MIME-ENCRYPTED MESSAGE ********<br>\n" . "Subject: " . $originalSubject . "<br><br>\n" . $part->getContent());
             }
             if ($part->getType() == Zend\Mime\Mime::TYPE_TEXT) {
                 $part->setContent("******** PGP/MIME-ENCRYPTED MESSAGE ********\n" . "Subject: " . $originalSubject . "\n\n" . $part->getContent());
             }
         }
     } else {
         $message->setBody("******** PGP/MIME-ENCRYPTED MESSAGE ********\n" . "Subject: " . $originalSubject . "\n\n" . $body);
     }
     $originalHeaders = parent::prepareHeaders($message);
     $originalBody = parent::prepareBody($message);
     $recipients = array();
     foreach ($message->getTo() as $destination) {
         $recipients[] = $destination->getEmail();
     }
     foreach ($message->getCc() as $destination) {
         $recipients[] = $destination->getEmail();
     }
     foreach ($message->getBcc() as $destination) {
         $recipients[] = $destination->getEmail();
     }
     global $openpgplib;
     $pgpmime_msg = $openpgplib->prepareEncryptWithZendMail($originalHeaders, $originalBody, $recipients);
     $headers = $pgpmime_msg[0];
     // set pgp/mime headers from result array
     $this->OpenGPGStoreMailBody = $pgpmime_msg[1];
     // set pgp/mime encrypted message body from result array
     return $headers;
 }
Exemplo n.º 7
0
 public function paymentAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $subscriptionsession = new Container('subscriptionsession');
         $session = new Container('frontend');
         $bookingModel = new Bookings();
         $trans = new Transactions();
         $model = new Practitioners();
         $common = new Common();
         $consumer = new Consumers();
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         if ($request->getPost('usesavedcard') !== '1') {
             $data['name'] = $request->getPost('name_on_card');
             $data['email'] = $request->getPost('emailid');
             $card_type = $request->getPost('card_type');
             $data['card_no'] = $request->getPost('card_no');
             $data['month'] = $request->getPost('month');
             $data['year'] = $request->getPost('year');
             $data['cvv_no'] = $request->getPost('cvv_no');
             $data['amount'] = $subscriptionsession->serviceprice;
             $data['rememberme'] = $request->getPost('rememberme');
             $data['use_for_renew'] = $request->getPost('use_for_renew');
             $data['currency'] = $subscriptionsession->currency;
             $result = $trans->processPayment($this->getServiceLocator()->get('Config'), $data);
         } else {
             $savedCard_details = $common->getUserCardDetails($api_url, array('user_id' => $session->userid));
             $cardDetails = end($savedCard_details);
             /* get saved card details : statr */
             $details = $trans->getcarddetails($this->getServiceLocator()->get('Config'), $cardDetails['creditCardDetails_token']);
             if (is_object($details) && isset($details->last4) && isset($details->cardType)) {
                 $data['card_no'] = $details->last4;
                 if ($details->cardType == "Visa") {
                     $card_type = 1;
                 } else {
                     if ($details->cardType == "MasterCard") {
                         $card_type = 2;
                     } else {
                         if ($details->cardType == "American Express") {
                             $card_type = 3;
                         }
                     }
                 }
             }
             /* get saved card details : statr */
             $data['customerDetails_id'] = $cardDetails['customerDetails_id'];
             $data['paymentMethodToken'] = $cardDetails['creditCardDetails_token'];
             $data['amount'] = $subscriptionsession->serviceprice;
             $data['currency'] = $subscriptionsession->currency;
             $result = $trans->processPayment($this->getServiceLocator()->get('Config'), $data, '1');
         }
         if ($result['status'] == 1) {
             // save user card details
             if ($data['rememberme'] == 1 || $data['use_for_renew'] == "1") {
                 $usersCardDetails = array();
                 $usersCardDetails['user_id'] = $session->userid;
                 $usersCardDetails['creditCardDetails_token'] = $result['creditCardDetails_token'];
                 $usersCardDetails['customerDetails_id'] = $result['customerDetails_id'];
                 $usersCardDetails['use_for_renew'] = $data['use_for_renew'] == 1 || $data['use_for_renew'] == "1" ? 1 : 0;
                 $usersCardDetails['card_expiration_hash'] = md5($data['month'] . '-' . $data['year']);
                 //$response = $bookingModel->addUsersCardDetails($api_url, $usersCardDetails);
                 $response = $trans->updateCard($this->getServiceLocator()->get('Config'), $usersCardDetails);
             }
             $subscriptionData = array();
             $subscriptionData['subscription_duration_id'] = $subscriptionsession->subscription_duration_id;
             $subscriptionData['payment_status_id'] = 7;
             $subscriptionData['site_commision'] = "0";
             $subscriptionData['status_id'] = 1;
             $subscriptionData['user_id'] = $session->userid;
             $subscriptionData['invoice_total'] = str_replace(array('USD$', 'CAD$', '$'), array('', '', ''), $subscriptionsession->serviceprice);
             $subscriptionData['created_by'] = $session->userid;
             $subscriptionData['invoice_status'] = 1;
             $subscriptionData['amount'] = str_replace(array('USD$', 'CAD$', '$'), array('', '', ''), $subscriptionsession->serviceprice);
             $subscriptionData['currency'] = $subscriptionsession->currency;
             $subscriptionData['payment_date'] = date('Y-m-d H:i:s');
             $subscriptionData['amount_paid'] = $subscriptionsession->serviceprice;
             $subscriptionData['transaction_id'] = $result['transaction_id'];
             $subscriptionData['payment_instrument_no'] = strlen($data['card_no']) > 4 ? substr($data['card_no'], strlen($data['card_no']) - 4, 4) : $data['card_no'];
             $subscriptionData['payment_method_id'] = $card_type;
             $subscriptionData['payment_status'] = 7;
             $subscriptionData['subscription_start_date'] = date('Y-m-d');
             $subscriptionData['sale_type'] = 1;
             /* 1 for subscription */
             $subscriptionData['subscription_end_date'] = $subscriptionsession->subscription_end_date;
             //$subscriptionData['user_card_id'] = $result['user_card_id'];
             $response = $bookingModel->addBooking($api_url, $subscriptionData);
             if ($response['status'] == 1 && isset($response['id'])) {
                 /* Send email code starts here */
                 $common = new Common();
                 if ($template = $common->emailTemplate($api_url, 11)) {
                     //$sp_details = $model->getSPDetails($api_url, $bookingsession->sp_id);
                     //$user_details = $consumer->getConsumerdetails($api_url, $session->userid);
                     $user_details = $model->getSPDetails($api_url, $session->userid);
                     $user_details['address'] = json_decode($user_details['address'][0], true);
                     $user_details['contact'] = json_decode($user_details['contact'][0], true);
                     $data = $bookingModel->getBookings($api_url, '', '', '', '', '', '', $response['id'], 'subscription');
                     $view = new viewModel(array('booking_details' => $data['results'], 'user_details' => $user_details));
                     $view->setTemplate('application/membership/printinvoice.phtml');
                     $printData = $this->getServiceLocator()->get('viewrenderer')->render($view);
                     // Store in PDF format
                     $dompdf = new \DOMPDF();
                     $dompdf->load_html($printData);
                     $dompdf->render();
                     $output = $dompdf->output();
                     $attachment = new MimePart($output);
                     $attachment->type = 'application/pdf';
                     $attachment->filename = 'invoice.pdf';
                     $attachment->encoding = \Zend\Mime\Mime::ENCODING_BASE64;
                     $attachment->disposition = \Zend\Mime\Mime::DISPOSITION_ATTACHMENT;
                     $mail = new Message();
                     $transport = new \Zend\Mail\Transport\Sendmail();
                     $html = new MimePart(preg_replace('/{{user_name}}/i', '<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>', $template['content']));
                     $html->type = "text/html";
                     $body = new MimeMessage();
                     $body->setParts(array($html, $attachment));
                     $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($user_details['email'], '')->setSubject($template['subject']);
                     $transport->send($mail);
                     /* Send email code ends here */
                 }
                 // unset all sessions
                 $subscriptionsession->offsetUnset('currency');
                 $subscriptionsession->offsetUnset('serviceprice');
                 $subscriptionsession->offsetUnset('subscription_duration_id');
                 $subscriptionsession->offsetUnset('subscription_end_date');
                 echo json_encode(array('status' => '1', 'msg' => 'Subscription updated successfully. <br /> Redirecting to invoice page..!!', 'subscription_id' => $response['id']));
             } else {
                 echo json_encode(array('status' => '0', 'msg' => 'Transaction completed successfully with Transaction Id <strong>' . $result['transaction_id'] . '</strong>. <br /> Failed to complete your request. Please contact to site admin..!!', 'errors' => $response['data']));
             }
         } else {
             echo json_encode($result);
         }
     }
     exit;
 }
 public function sendmailAction()
 {
     $sendcode = rand();
     $session = new Container('frontend');
     $api = new Api();
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $model = new Practitioners();
     $common = new Common();
     if ($session->email == $this->getRequest()->getPost('email')) {
         if ($template = $common->emailTemplate($api_url, 8)) {
             $mail = new Message();
             $transport = new \Zend\Mail\Transport\Sendmail();
             $html = new MimePart(preg_replace('/{{code}}/i', '<strong>' . $sendcode . '</strong>', $template['content']));
             $html->type = "text/html";
             $body = new MimeMessage();
             $body->setParts(array($html));
             $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($session->email, '')->setSubject($template['subject']);
             try {
                 $verify_session = new Container('verify');
                 $transport->send($mail);
                 $api = new Api();
                 $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
                 $data = array('user_id' => $session->userid, 'verification_type_id' => $verify_session->type, 'verification_code' => $sendcode, 'created_date' => date('Y-m-d H:i:s'));
                 $getvalue = $this->checkuserexistence();
                 if (count($getvalue) > 0) {
                     // verification code  time out
                     if ($getvalue['timeverification'] == false) {
                         $url = $api_url . "/api/userverification/" . $getvalue['id'] . "/";
                         $type = "PUT";
                     }
                 } else {
                     // new user
                     $url = $api_url . "/api/userverification/";
                     $type = "POST";
                 }
                 $res = $api->curl($url, $data, $type);
                 //$msg = ($res->getStatusCode()==201)? ('Your verified code was sent to your email'):('Error in create verified code');
                 //$error = ($res->getStatusCode()==201)? false: true;
                 $msg = 'Your verification code was sent to your email';
                 $error = false;
             } catch (Exception $e) {
                 $error = true;
                 $msg = 'Unable to send email';
             }
         } else {
             $error = true;
             $msg = 'Unable to find mail template..!!';
         }
     } else {
         $error = true;
         $msg = 'Sorry this is not registered email id';
     }
     echo json_encode(array('msg' => $msg, 'error' => $error));
     exit;
 }
 public function mailbusinesscardAction()
 {
     $api = new Api();
     $model = new Practitioners();
     $common = new Common();
     $session = new Container('frontend');
     $request = $this->getRequest();
     //echo "get value:-:".$request->getPost('imageUrl'); die;
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $imgname = $request->getPost('imageUrl') == 'verso' ? 'verso' : 'recto';
     $url = rtrim($this->getServiceLocator()->get('config')['basepath']['url'], '/');
     $logo = $url . '/img/business-logo.png';
     $user_details = $model->getSPDetails($api_url, $session->userid);
     $profileurl = $this->getServiceLocator()->get('config')['basepath']['url'] . 'practitioner/view/' . $user_details['id'];
     /* commented by pi20jan
               if ($imgname == 'recto') {
               $address = $cellphone = 'Not Available';
     
               // getting address
               if (isset($user_details['work_address']) && is_array($user_details['work_address']) && count($user_details['work_address']) > 0) {
               $mainAddress = json_decode($user_details['work_address'][0], true);
               $address = $mainAddress['city'].', '.$mainAddress['state_name'];
               }
     
               // getting contact details
               if (isset($user_details['contact']) && is_array($user_details['contact']) && count($user_details['contact']) > 0) {
               $contactDetails = json_decode($user_details['contact'][0], true);
               $cellphone = $contactDetails['cellphone'];
               }
     
               $services_count = $this->getservicesdata($session->userid, $api, $api_url); // get all services list
               $bussCategoryName = isset($services_count['results'][0]['parent_category'])?$services_count['results'][0]['parent_category']:'Not Available';
     
               $patterns = array('/{{id}}/i', '/{{card_logo}}/i', '/{{main_category}}/i', '/{{user_name}}/i', '/{{url}}/i', '/{{cellphone}}/i', '/{{address}}/i', '/{{profile_url}}/i');
               $replacements = array($session->userid, $logo, $bussCategoryName, $user_details['first_name'] . ' ' . $user_details['last_name'], $url, $cellphone, $address, $profileurl);
     
               //Get tamplate
               $template = $common->emailTemplate($api_url, 25);
     
               } else {
     
               // Get services
               $getservices = $request->getPost('servicename');
     
               if (count($services['services_list']) > 0) {
               $getservices = array();
               foreach ($services['services_list'] as $name => $value) {
               array_push($getservices, $value['name']);
               }
               $getservices = implode(',', $getservices);
               }
     
               //$logo = $this->getServiceLocator()->get('config')['basepath']['url'].'img/business-logo.png';
               $bgimage = "background:url('".$url."/img/bg_" . $imgname . ".jpg') no-repeat center center;";
     
               $patterns = array('/{{card_logo}}/i', '/{{user_id}}/i', '/{{user_name}}/i', '/{{service_name}}/i', '/{{url_path}}/i', '/{{back_ground}}/i');
               $replacements = array($logo, '<strong>' . $user_details['id'] . '</strong>', '<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>', '<strong>' . $getservices . '</strong>', $loginurl, $bgimage);
               //$replacements = array($logo,$request->getPost('url'),'<strong>'.$user_details['first_name'].' '.$user_details['last_name'].'</strong>','<strong>'.$getservices.'</strong>',$loginurl);
               //Get tamplate
               $template = $common->emailTemplate($api_url, 24);
               }
              */
     $address = $cellphone = 'Not Available';
     // getting address
     if (isset($user_details['work_address']) && is_array($user_details['work_address']) && count($user_details['work_address']) > 0) {
         $mainAddress = json_decode($user_details['work_address'][0], true);
         $address = $mainAddress['city'] . ', ' . $mainAddress['state_name'];
     }
     // getting contact details
     if (isset($user_details['contact']) && is_array($user_details['contact']) && count($user_details['contact']) > 0) {
         $contactDetails = json_decode($user_details['contact'][0], true);
         $cellphone = $contactDetails['cellphone'];
     }
     $services_count = $this->getservicesdata($session->userid, $api, $api_url);
     // get all services list
     $parentService = isset($services_count['results'][0]['category_id']) ? $model->getParentService($api_url, $services_count['results'][0]['category_id']) : 'Not Available';
     $bussCategoryName = $parentService ? $parentService['category_name'] : 'Not Avaialable';
     //$bussCategoryName = isset($services_count['results'][0]['parent_category'])?$services_count['results'][0]['parent_category']:'Not Available';
     $back_ground = $imgname == 'recto' ? '' : 'background: url(' . $url . '/img/bg_verso.jpg) no-repeat scroll center center transparent;';
     $patterns = array('/{{id}}/i', '/{{card_logo}}/i', '/{{main_category}}/i', '/{{user_name}}/i', '/{{url}}/i', '/{{cellphone}}/i', '/{{address}}/i', '/{{profile_url}}/i', '/{{back_ground}}/i');
     $replacements = array($session->userid, $logo, $bussCategoryName, $user_details['first_name'] . ' ' . $user_details['last_name'], $url, $cellphone, $address, $profileurl, $back_ground);
     $template = $imgname == 'recto' ? $common->emailTemplate($api_url, 25) : $common->emailTemplate($api_url, 24);
     $mail = new Message();
     $transport = new \Zend\Mail\Transport\Sendmail();
     $html = new MimePart(stripslashes(preg_replace($patterns, $replacements, stripslashes($template['content']))));
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->setParts(array($html));
     $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($request->getPost('email'), '')->setSubject($template['subject']);
     $transport->send($mail);
     echo json_encode(array('status' => 1, 'msg' => 'Business card sent to the email address..!!'));
     exit;
 }
Exemplo n.º 10
0
 public function sendMail($api_url, $to, $from = '', $template = '', $content = array('subject' => '', 'message' => ''), $pattern = array(), $replace = array(), $attachment = false, $Bcc = '')
 {
     $mail = new Message();
     $body = new MimeMessage();
     $transport = new \Zend\Mail\Transport\Sendmail();
     if ($template != '') {
         if ($template = $this->emailTemplate($api_url, $template)) {
             $html = new MimePart(preg_replace($pattern, $replace, $template['content']));
             $subject = $template['subject'];
         }
     } else {
         if ($content['message'] != '') {
             $html = new MimePart(preg_replace($pattern, $replace, $content['message']));
             $subject = $content['subject'];
         }
     }
     if ($html) {
         $html->type = "text/html";
         if ($attachment != false) {
             $body->setParts(array($html, $attachment));
         } else {
             $body->setParts(array($html));
         }
         $from = $from != '' ? $from : $template['fromEmail'];
         try {
             $mail->setBody($body)->setFrom($from, 'Ovessence')->addTo($to, '')->setSubject(preg_replace($pattern, $replace, $subject));
             if ($Bcc != '') {
                 $mail->addBcc($Bcc, '');
             }
             $transport->send($mail);
             return true;
         } catch (\Exception $ex) {
             //echo $ex->getMessage(); exit;
             return false;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 11
0
 public function referspAction()
 {
     $session = new Container('frontend');
     if ($this->getRequest()->isXmlHttpRequest()) {
         $request = $this->getRequest();
         if ($request->getPost('user') != "" && $request->getPost('email') != "") {
             $model = new Wishlists();
             $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
             if ($template = $model->emailTemplate($api_url, 7)) {
                 $user_details = $model->getCustomerDetails($api_url, $session->userid);
                 $profile_url = $this->getServiceLocator()->get('config')['basepath']['url'] . 'practitioner/view/' . $request->getPost('user');
                 $patterns = array('/{{user_name}}/i', '/{{profile_link}}/i');
                 $replacements = array('<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>', '<strong>' . $profile_url . '</strong>');
                 $mail = new Message();
                 $transport = new \Zend\Mail\Transport\Sendmail();
                 $html = new MimePart(preg_replace($patterns, $replacements, $template['content']));
                 $html->type = "text/html";
                 $body = new MimeMessage();
                 $body->setParts(array($html));
                 $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($request->getPost('email'), '')->setSubject($template['subject']);
                 $transport->send($mail);
                 echo json_encode(array('status' => 1, 'msg' => 'Selected practitioner successfully referred to the given email address..!!'));
             } else {
                 echo json_encode(array('status' => 0, 'msg' => 'Unable to find mail template..!!'));
             }
         } else {
             echo json_encode(array('status' => 0, 'msg' => 'Unable to Refer..!!'));
         }
     }
     exit;
 }
 public function indexAction()
 {
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     $api = new Api();
     $auth = new FrontEndAuth();
     $error = "";
     $redirectUrl = array('controller' => 'index');
     if ($auth->hasIdentity()) {
         return $this->redirect()->toRoute(null, $redirectUrl);
     }
     $form = new ForgetPasswordForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $model = new ForgetPassword();
         $form->setInputFilter($model->getInputFilter());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             unset($data['submit']);
             $random_password = $model->generateRandomPassword();
             $data['password'] = $random_password;
             $session = new Container('frontend');
             $url = $api_url . "/api/useractivity/";
             $data['op'] = 'forgotpassword';
             $res = $api->curl($url, $data, "POST");
             //var_dump($res); die;
             if ($res->getStatusCode() == 200) {
                 $model = new Common();
                 if ($template = $model->emailTemplate($api_url, 3)) {
                     $content = json_decode($res->getBody(), true);
                     // '{{user_first_name}}', '{{username}}', '{{password}}'
                     //$content['first_name'], $content['user_name'], $random_password), $template['content']);
                     $patterns = array('/{{user_first_name}}/i', '/{{username}}/i', '/{{password}}/i');
                     $replacements = array($content['first_name'], '<strong>' . $content['user_name'] . '</strong>', '<strong>' . $random_password . '</strong>', '<strong>' . $getservices . '</strong>');
                     $mail = new Message();
                     $transport = new \Zend\Mail\Transport\Sendmail();
                     $html = new MimePart(preg_replace($patterns, $replacements, $template['content']));
                     $html->type = "text/html";
                     $body = new MimeMessage();
                     $body->setParts(array($html));
                     $url = $api_url . "/api/useractivity/";
                     $data = array('email' => $content['email'], 'password' => $random_password);
                     $data['op'] = 'resetpassword';
                     $res = $api->curl($url, $data, "POST");
                     if ($res->getStatusCode() == 200) {
                         $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($content['email'], '')->setSubject($template['subject']);
                         $transport->send($mail);
                         $error = false;
                         $msg = "A mail has been send to " . $content['email'] . " ,Please check ";
                     } else {
                         $error = true;
                         $msg = "Unable to set password..!! ";
                     }
                     // echo json_encode(array('status' => 1, 'msg' => 'Business card sent to the email address..!!'));
                 } else {
                     $error = true;
                     $msg = "Unable to find mail template..!!";
                     //echo json_encode(array('status' => 0, 'msg' => 'Unable to find mail template..!!'));
                 }
                 /*
                                     $content = json_decode($res->getBody(), true);
                                                         
                                     $forget_pass_url = $api_url."/api/emailtemplate/3/";
                                     
                                     $forget_pass_res = $api->curl($forget_pass_url, array(), "GET");
                                     //print_r($forget_pass_res); die;
                                     if($forget_pass_res->getStatusCode() == 200) {
                                         $template = json_decode($forget_pass_res->getBody(), true);
                                         
                                         $template_data = str_replace(array('{{user_first_name}}', '{{username}}', '{{password}}' ), array($content['first_name'], $content['user_name'], $random_password), $template['content']);
                                         
                                         $wp_user_detail = $auth->wordpress_user_detail($content['user_name']);
                                         $auth->wordpress_set_password($random_password, $wp_user_detail->ID);
                                         
                                         $reset_data['op'] = 'resetpassword';
                                         $reset_data['email'] = $content['email'];
                                         $reset_data['password'] = $random_password;
                 						$reset_res = $api->curl($url, $reset_data, "POST");
                                         
                                         $mail = new \Zend\Mail\Message();                 
                                     
                                         $html = new \Zend\Mime\Part($template_data);
                                         $html->type = "text/html";
                 
                                         $body = new \Zend\Mime\Message();
                                         $body->setParts(array($html));
                 						//$content['email']
                                         $mail->setBody($body)
                                              ->setFrom($template['fromEmail'], 'Ovessence')
                                              ->addTo('*****@*****.**', $content['first_name'].' '.$content['last_name'])
                                              ->setSubject($template['subject']);
                                         $transport = new \Zend\Mail\Transport\Sendmail($template['fromEmail']);
                                         $transport->send($mail);                    
                                         $error = "A mail has been send to ". $content['email'] ." ,Please check ";
                                     
                                     }*/
             } else {
                 if ($res->getStatusCode() == "404") {
                     $error = true;
                     $msg = "User with given email does not exist";
                 } else {
                     $error = true;
                     $msg = $res->getReasonPhrase();
                 }
             }
         }
     }
     $view = new ViewModel(array('form' => $form, 'error' => $error, 'msg' => $msg));
     $view->setTemplate('application/forgetPassword/index.phtml');
     return $view;
 }
Exemplo n.º 13
0
 public function sendmailHTML($to_email, $to_name, $subject, $htmltext)
 {
     $message = new \Zend\Mail\Message();
     $message->addTo($to_email, $to_name)->setFrom('*****@*****.**', 'DiscoveryCRM')->setSubject($subject);
     // $htmltext = '<b>heii, <i>sorry</i>, i\'m going late</b>';
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         $transport = new \Zend\Mail\Transport\Smtp();
         $options = new \Zend\Mail\Transport\SmtpOptions(array('host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => 'Discovery@123'), 'port' => 587));
         $html = new \Zend\Mime\Part($htmltext);
         $html->type = "text/html";
         $body = new \Zend\Mime\Message();
         $body->addPart($html);
         $message->setBody($body);
         $transport->setOptions($options);
         $transport->send($message);
     } else {
         $bodyPart = new \Zend\Mime\Message();
         $bodyMessage = new \Zend\Mime\Part($htmltext);
         $bodyMessage->type = 'text/html';
         $bodyPart->setParts(array($bodyMessage));
         $message->setBody($bodyPart);
         $message->setEncoding('UTF-8');
         $transport = new \Zend\Mail\Transport\Sendmail();
         $transport->send($message);
     }
     return 1;
 }
Exemplo n.º 14
0
 public static function send_email_zend($email, $betreff, $text_plain, $text_html = null, $mail_tag = null)
 {
     $mail = new Zend\Mail\Message();
     $mail->setFrom(Yii::app()->params["adminEmail"], Yii::app()->params["adminEmailName"]);
     $mail->addTo($email, $email);
     $mail->setSubject($betreff);
     $mail->setEncoding("UTF-8");
     if ($text_html !== null) {
         $converter = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($text_html);
         $converter->setStripOriginalStyleTags(false);
         $converter->setUseInlineStylesBlock(true);
         $converter->setEncoding("UTF-8");
         $converter->setExcludeMediaQueries(true);
         $converter->setCleanup(false);
         $text_html = $converter->convert();
         $text_part = new Zend\Mime\Part($text_plain);
         $text_part->type = "text/plain";
         $text_part->charset = "UTF-8";
         $html_part = new Zend\Mime\Part($text_html);
         $html_part->type = "text/html";
         $html_part->charset = "UTF-8";
         $mimem = new Zend\Mime\Message();
         $mimem->setParts([$text_part, $html_part]);
         $mail->setBody($mimem);
         $mail->getHeaders()->get('content-type')->setType('multipart/alternative');
     } else {
         $mail->setBody($text_plain);
         $headers = $mail->getHeaders();
         $headers->removeHeader('Content-Type');
         $headers->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8');
     }
     $transport = new Zend\Mail\Transport\Sendmail();
     $transport->send($mail);
 }
 public function changeStatusAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $id = $request->getPost('id');
         $status = $request->getPost('status', '1');
         if ($id != null && $status != null) {
             $this->getServiceProviderTable()->changeStatus($id, $status);
             if ($status == 9) {
                 if ($emailTemplate = $this->getServiceLocator()->get('Admin\\Model\\EmailtemplatesTable')->getEmailtemplate(4)) {
                     $mail = new Message();
                     $transport = new \Zend\Mail\Transport\Sendmail();
                     foreach ($id as $user_id) {
                         $user_details = $this->getServiceProviderTable()->getUserDetails($user_id);
                         $html = new MimePart(preg_replace('/{{user_name}}/i', '<strong>' . $user_details->first_name . ' ' . $user_details->last_name . '</strong>', $emailTemplate->content));
                         $html->type = "text/html";
                         $body = new MimeMessage();
                         $body->setParts(array($html));
                         $mail->setBody($body)->setFrom($emailTemplate->fromEmail, 'Ovessence')->addTo($user_details->email, $user_details->first_name . ' ' . $user_details->last_name)->setSubject($emailTemplate->subject);
                         $transport->send($mail);
                     }
                 }
             }
             echo json_encode(array("msg" => "Status successfully changed..!!"));
         } else {
             echo json_encode(array("msg" => "Failed to change the status..!!"));
         }
         exit;
     }
 }