public function saveFiles($fileArray) { if (empty($fileArray)) { return array(); } // Init connection $this->initConnection(); $savedFiles = array(); @ini_set('SMTP', Mage::getStoreConfig('system/smtp/host')); @ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port')); $charset = "utf-8"; #$charset = "iso-8859-1"; $mail = new Zend_Mail($charset); $setReturnPath = Mage::getStoreConfig('system/smtp/set_return_path'); switch ($setReturnPath) { case 1: $returnPathEmail = $this->getDestination()->getEmailSender(); break; case 2: $returnPathEmail = Mage::getStoreConfig('system/smtp/return_path_email'); break; default: $returnPathEmail = null; break; } if ($returnPathEmail !== null) { $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $returnPathEmail); Zend_Mail::setDefaultTransport($mailTransport); } $mail->setFrom($this->getDestination()->getEmailSender(), $this->getDestination()->getEmailSender()); foreach (explode(",", $this->getDestination()->getEmailRecipient()) as $email) { if ($charset === "utf-8") { $mail->addTo($email, '=?utf-8?B?' . base64_encode($email) . '?='); } else { $mail->addTo($email, $email); } } foreach ($fileArray as $filename => $data) { if ($this->getDestination()->getEmailAttachFiles()) { $attachment = $mail->createAttachment($data); $attachment->filename = $filename; } $savedFiles[] = $filename; } #$mail->setSubject($this->_replaceVariables($this->getDestination()->getEmailSubject(), $firstFileContent)); if ($charset === "utf-8") { $mail->setSubject('=?utf-8?B?' . base64_encode($this->_replaceVariables($this->getDestination()->getEmailSubject(), implode("\n\n", $fileArray))) . '?='); } else { $mail->setSubject($this->_replaceVariables($this->getDestination()->getEmailSubject(), implode("\n\n", $fileArray))); } $mail->setBodyText(strip_tags($this->_replaceVariables($this->getDestination()->getEmailBody(), implode("\n\n", $fileArray)))); $mail->setBodyHtml($this->_replaceVariables($this->getDestination()->getEmailBody(), implode("\n\n", $fileArray))); try { $mail->send(Mage::helper('xtcore/utils')->getEmailTransport()); } catch (Exception $e) { $this->getTestResult()->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('Error while sending email: %s', $e->getMessage())); return false; } return $savedFiles; }
/** * @param string $name * @return string * @throws \Zend_Mail_Exception */ public function forgotPassword($name) { $kga = $this->getKga(); $database = $this->getDatabase(); $is_customer = $database->is_customer_name($name); $mail = new Zend_Mail('utf-8'); $mail->setFrom($kga['conf']['adminmail'], 'Kimai - Open Source Time Tracking'); $mail->setSubject($kga['lang']['passwordReset']['mailSubject']); $transport = new Zend_Mail_Transport_Sendmail(); $passwordResetHash = str_shuffle(MD5(microtime())); if ($is_customer) { $customerId = $database->customer_nameToID($name); $customer = $database->customer_get_data($customerId); $database->customer_edit($customerId, array('passwordResetHash' => $passwordResetHash)); $mail->addTo($customer['mail']); } else { $userId = $database->user_name2id($name); $user = $database->user_get_data($userId); $database->user_edit($userId, array('passwordResetHash' => $passwordResetHash)); $mail->addTo($user['mail']); } Kimai_Logger::logfile('password reset: ' . $name . ($is_customer ? ' as customer' : ' as user')); $ssl = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; $url = ($ssl ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/forgotPassword.php?name=' . urlencode($name) . '&key=' . $passwordResetHash; $message = $kga['lang']['passwordReset']['mailMessage']; $message = str_replace('%{URL}', $url, $message); $mail->setBodyText($message); try { $mail->send($transport); return $kga['lang']['passwordReset']['mailConfirmation']; } catch (Zend_Mail_Transport_Exception $e) { return $e->getMessage(); } }
/** * @param string $subject * The subject. May contain variable references to memebrs * of the $fields array. * @param string $view * The name of a view * @param array $fields * The fields referenced in the subject and/or view * @param array $optoins * Array of options. Can include: * "html" => Defaults to false. Whether to send as HTML email. * "name" => A human-readable name in addition to the address. * "from" => An array of email_address => human_readable_name */ function sendMessage($subject, $view, $fields = array(), $options = array()) { if (!isset($options['from'])) { $url_parts = parse_url(Pie_Request::baseUrl()); $domain = $url_parts['host']; $options['from'] = array("email_bot@" . $domain => $domain); } else { if (!is_array($options['from'])) { throw new Pie_Exception_WrongType(array('field' => '$options["from"]', 'type' => 'array')); } } // Set up the default mail transport $tr = new Zend_Mail_Transport_Sendmail('-f' . $this->address); Zend_Mail::setDefaultTransport($tr); $mail = new Zend_Mail(); $from_name = reset($options['from']); $mail->setFrom(key($options['from']), $from_name); if (isset($options['name'])) { $mail->addTo($this->address, $options['name']); } else { $mail->addTo($this->address); } $subject = Pie::expandString($subject, $fields); $body = Pie::view($view, $fields); $mail->setSubject($subject); if (empty($options['html'])) { $mail->setBodyText($body); } else { $mail->setBodyHtml($body); } $mail->send(); return true; }
$this->_moduleName = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $this->view->moduleName = $this->_moduleName; // echo $this->_moduleName;exit; // Breadcrumb $this->_generateBreadcrumb(); // Title dari website // Nama controller $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); // Nama action $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $this->view->sess = $this->_sess; //generate header image $highlightDb = new Model_DbTable_Highlight(); $highlight = $highlightDb->getMainType(3, $this->_languageId); $this->view->imageData = $highlight; // Untuk munculin list kategori di menu $categoryDb = new Model_Category(); $categories = $categoryDb->getAllHierarchyByLanguage(); $this->view->categories = $categories; $this->view->headTitle('Kebudayaan Indonesia'); $partnerDb = new Model_DbTable_Partner(); // Data $partner = $partnerDb->getAllWithDesc($this->_languageId); $partner = $partnerDb->fetchAll($partner); $this->view->partner = $partner->toArray(); // echo '<pre>'; // print_r($categories); } /** * Fungsi untuk generate breadcrumb. Fungsi ini akan di-override sama * controller anak2nya. Disengaja untuk dikosongin */ protected function _generateBreadcrumb() {
/** * Send email notification to moderators when a new comment is posted * * @todo move logic to model / library class * * @param HumanHelp_Model_Comment $comment * @param HumanHelp_Model_Page $page */ public function _sendNewCommentEmail(HumanHelp_Model_Comment $comment, HumanHelp_Model_Page $page) { $config = Zend_Registry::get('config'); $emailTemplate = new Zend_View(); $emailTemplate->setScriptPath(APPLICATION_PATH . '/views/emails'); $emailTemplate->addHelperPath(APPLICATION_PATH . '/views/helpers', 'HumanHelp_View_Helper_'); $emailTemplate->setEncoding('UTF-8'); $emailTemplate->comment = $comment; $emailTemplate->page = $page; $emailTemplate->baseUrl = 'http://' . $_SERVER['HTTP_HOST'] . $this->view->baseUrl; $bodyHtml = $emailTemplate->render('newComment.phtml'); $bodyText = $emailTemplate->render('newComment.ptxt'); $mail = new Zend_Mail(); $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE)->setBodyHtml($bodyHtml, 'UTF-8')->setBodyText($bodyText, 'UTF-8')->setSubject("New comment on '{$page->getTitle()}' in '{$page->getBook()->getTitle()}'")->setFrom($config->fromAddress, $config->fromName); if (is_object($config->notifyComments)) { foreach ($config->notifyComments->toArray() as $rcpt) { $mail->addTo($rcpt); } } else { $mail->addTo($config->notifyComments); } if ($config->smtpServer) { $transport = new Zend_Mail_Transport_Smtp($config->smtpServer, $config->smtpOptions->toArray()); } else { $transport = new Zend_Mail_Transport_Sendmail(); } $mail->send($transport); }
/** * Send an email * * @param mixed $emails String or array or emails * @param string $subject * @param string $message * @return boolean */ public static function sendEmail($emails, $subject, $message, $fromName, $fromEmail) { $mail = new Zend_Mail(); if (is_array($emails)) { foreach ($emails as $email) { $mail->addTo($email); } } else { $mail->addTo($emails); } $mail->setSubject($subject); $mail->setBodyHtml($message); $mail->setFrom($fromEmail, $fromName); $sent = true; try { $mail->send(); } catch (Exception $e) { $sent = false; $error = $e->getMessage(); // Logger::LogEmail($e->getMessage(), Zend_Log::ERR); // Logger::LogEmail('Email: ' . $email, Zend_Log::INFO); // Logger::LogEmail('Subject: ' . $subject, Zend_Log::INFO); // Logger::LogEmail('Message: ' . $message, Zend_Log::INFO); } return [Sent => $sent, Message => $error]; }
/** * Odesle E-mail * * @param string $recipient E-mail prijemce */ public function send($recipient) { $smtpOptions = array('auth' => 'login', 'username' => '*****@*****.**', 'password' => 'opticau51', 'ssl' => 'ssl', 'port' => 465); $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $smtpOptions); $this->_mail->setBodyHtml($this->_bodyText); $this->_mail->addTo($recipient); $this->_mail->send($mailTransport); }
/** * Notifies the customer of their delivery. * * @param \IocExample\Model\Customer $customer * @param \IocExample\Model\Order $order * @return void */ public function notifyCustomerOfDelivery(Customer $customer, Order $order) { $this->_mailer->setFrom('*****@*****.**', 'Grumpy Baby Orders'); $this->_mailer->setSubject('Order #' . $order->getId() . ' out for Delivery'); $this->_mailer->setBodyText('Your order is being shipped!'); $this->_mailer->addTo($customer->getEmail(), $customer->getName()); $this->_mailer->send(); }
/** * Generate token and update user record. * @see Doctrine_Record_Listener::postInsert() */ public function postInsert(Doctrine_Event $event) { $this->_user = $event->getInvoker(); $this->assignViewVariables(); $this->_mail->setBodyHtml($this->renderView('html')); $this->_mail->setBodyText($this->renderView('plain')); $this->_mail->setSubject($this->_subject); $this->_mail->addTo($this->_user->email, $this->_nickname); $this->_mail->send(); }
public function send($template, array $values = array()) { // create a new mail $mail = new Zend_Mail('UTF-8'); if (isset($values['to'])) { if (is_array($values['to'])) { foreach ($values['to'] as $address) { $mail->addTo($address); } } else { $mail->addTo($values['to']); } unset($values['to']); } else { throw new Exception('to not send in $values'); } // set cc if (isset($values['cc'])) { if (is_array($values['cc'])) { foreach ($values['cc'] as $address) { $mail->addCc($address); } } else { $mail->addCc($values['cc']); } unset($values['cc']); } // set bcc if (isset($values['bcc'])) { if (is_array($values['bcc'])) { foreach ($values['bcc'] as $address) { $mail->addBcc($address); } } else { $mail->addBcc($values['bcc']); } unset($values['bcc']); } // get the template $templateModel = new Core_Model_Templates(); $data = $templateModel->show($template, $values); // set subject and body $mail->setSubject($data['subject']); $mail->setBodyText($data['body']); if (empty(Daiquiri_Config::getInstance()->mail->debug)) { $mail->send(); } else { Zend_Debug::dump($mail->getRecipients()); Zend_Debug::dump($mail->getSubject()); Zend_Debug::dump($mail->getBodyText()); } }
/** * * @param Zend_Controller_Request_Abstract$request * @param Zend_Mail|null $mailer * @param string|null $to */ public function __construct($request, $config, $mailer = NULL) { $this->_request = $request; if (isset($mailer)) { $this->_mailer = $mailer; } else { $this->_mailer = new Zend_Mail('UTF-8'); } $this->_mailer->addTo($config->contactEmail); if (!empty($config->fromEmail)) { $this->_mailer->setFrom($config->fromEmail); } }
/** * load the template and send the message * * @param string $recipient * @param array $from * @param string $subject * @param string $template * @param array $data * @param string $cc * @return bool */ public function send($recipient, $from = array(), $subject, $message, $cc = false) { $config = Zend_Registry::get('config'); $this->_view->addScriptPath($config->filepath->emailTemplates); $this->_view->emailBody = $message; $this->_mail->setBodyHtml($this->_view->render('template.phtml')); $this->_mail->setFrom($from[0], $from[1]); $this->_mail->addTo($recipient); if ($cc) { $this->_mail->addCc($cc); } $this->_mail->setSubject($subject); return $this->_mail->send($this->_transport); }
/** * Send a mail based on the configuration in the emails table * * @throws EngineBlock_Exception in case there is no EmailConfiguration in emails table * @param $emailAddress the email address of the recipient * @param $emailType the pointer to the emails configuration * @param $replacements array where the key is a variable (e.g. {user}) and the value the string where the variable should be replaced * @return void */ public function sendMail($emailAddress, $emailType, $replacements) { $dbh = $this->_getDatabaseConnection(); $query = "SELECT email_text, email_from, email_subject, is_html FROM emails where email_type = ?"; $parameters = array($emailType); $statement = $dbh->prepare($query); $statement->execute($parameters); $rows = $statement->fetchAll(); if (count($rows) !== 1) { EngineBlock_ApplicationSingleton::getLog()->err("Unable to send mail because of missing email configuration: " . $emailType); return; } $emailText = $rows[0]['email_text']; foreach ($replacements as $key => $value) { // Single value replacement if (!is_array($value)) { $emailText = str_ireplace($key, $value, $emailText); } else { $replacement = '<ul>'; foreach ($value as $valElem) { $replacement .= '<li>' . $valElem . '</li>'; } $replacement .= '</ul>'; $emailText = str_ireplace($key, $replacement, $emailText); } } $emailFrom = $rows[0]['email_from']; $emailSubject = $rows[0]['email_subject']; $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($emailText, 'utf-8', 'utf-8'); $mail->setFrom($emailFrom, "SURFconext Support"); $mail->addTo($emailAddress); $mail->setSubject($emailSubject); $mail->send(); }
/** * @return Zend_Mail * @throws Zend_Mail_Protocol_Exception */ public static function getMail($name, $email, $feedback) { // can't use $this-_config 'cause it's a static function $configEmail = Zend_Registry::get('config')->email; switch (strtolower($configEmail->transport)) { case 'smtp': Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($configEmail->host, $configEmail->toArray())); break; case 'mock': Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock()); break; default: Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail()); } $mail = new Zend_Mail('UTF-8'); $mail->setBodyText(<<<EOD Dear Administrator, The community-id feedback form has just been used to send you the following: Name: {$name} E-mail: {$email} Feedback: {$feedback} EOD ); $mail->setFrom($configEmail->supportemail); $mail->addTo($configEmail->supportemail); $mail->setSubject('Community-ID feedback form'); return $mail; }
public function contatoAction() { if ($this->_request->isPost()) { $html = new Zend_View(); $html->setScriptPath(APPLICATION_PATH . '/modules/default/layouts/scripts/'); $title = 'Contato | Instag'; $to = '*****@*****.**'; $cc = '*****@*****.**'; $html->assign('title', $title); $html->assign('nome', $this->_request->getPost('nome')); $html->assign('email', $this->_request->getPost('email')); $html->assign('assunto', $this->_request->getPost('assunto')); $html->assign('mensagem', $this->_request->getPost('mensagem')); $mail = new Zend_Mail('utf-8'); $bodyText = $html->render('contato.phtml'); $config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => '*****@*****.**', 'password' => 'Inndeia123'); $transport = new Zend_Mail_Transport_Smtp('127.0.0.1', $config); $mail->addTo($to); $mail->addCc($cc); $mail->setSubject($title); $mail->setFrom($this->_request->getPost('email'), $this->_request->getPost('name')); $mail->setBodyHtml($bodyText); $send = $mail->send($transport); if ($send) { $this->_helper->flashMessenger->addMessage('Sua mensagem foi enviada com sucesso, em breve entraremos em contato.'); } else { $this->_helper->flashMessenger->addMessage('Falha no envio, tente novamente!'); } $this->_redirect('/index'); } }
public function runTest($params = array()) { $config = $this->_getConfig($params); $sock = false; try { $sock = fsockopen($config['host'], $config['port'], $errno, $errstr, 20); } catch (Exception $e) { } if ($sock) { Mage::helper('amsmtp')->debug('Connection test successful: connected to ' . $config['host'] . ':' . $config['port']); if ($config['test_email']) { $from = Mage::getStoreConfig('trans_email/ident_general/email'); Mage::helper('amsmtp')->debug('Preparing to send test e-mail to ' . $config['test_email'] . ' from ' . $from); $mail = new Zend_Mail(); $mail->addTo($config['test_email'])->setSubject(Mage::helper('amsmtp')->__('Amasty SMTP Email Test Message'))->setBodyText(Mage::helper('amsmtp')->__('If you see this e-mail, your configuration is OK.'))->setFrom($from); try { $mail->send($this->getTransport($params)); Mage::helper('amsmtp')->debug('Test e-mail was sent successfully!'); } catch (Exception $e) { Mage::helper('amsmtp')->debug('Test e-mail failed: ' . $e->getMessage()); return false; } } return true; } Mage::helper('amsmtp')->debug('Connection test failed: connection to ' . $config['host'] . ':' . $config['port'] . ' failed. Error: ' . $errstr . ' (' . $errno . ')'); return false; }
/** * * @param User_Form_Recovery $form * @return boolean */ public function userRecovery(User_Form_Recovery $form) { $answer = false; $user = Doctrine_Query::create()->from('User_Model_Mapper_User u')->select('u.username')->addSelect('u.password')->where('u.username = ?', $form->getValue('username')); if ($user->count() != '0') { $userRecovery = $user->fetchOne(); $ranges = array(range('a', 'z'), range('A', 'Z'), range(1, 9)); $length = 8; $pass = ''; for ($i = 0; $i < $length; $i++) { $rkey = array_rand($ranges); $vkey = array_rand($ranges[$rkey]); $pass .= $ranges[$rkey][$vkey]; } $hash = sha1($pass); $userRecovery->password = $hash; $userRecovery->save(); $mail = new Zend_Mail(); $mail->setBodyHtml('<p>Your new password.</p><p>Password: '******'</p>'); $mail->setFrom('*****@*****.**', 'Administrator'); $mail->addTo($userRecovery->email, $userRecovery->username); $mail->setSubject('Test password recovery'); $mail->send(); $answer = true; } return $answer; }
public function indexAction() { $helper = Mage::helper('multipledeals'); $storeId = Mage::app()->getStore()->getId(); if ($helper->isEnabled()) { //Mage::getModel('multipledeals/multipledeals')->refreshDeals(); if ($mainDeal = $helper->getDeal()) { $product = Mage::getModel('catalog/product')->setStore($storeId)->load($mainDeal->getProductId()); $product->setDoNotUseCategoryId(true); $this->_redirectUrl($product->getProductUrl()); return; } else { if (Mage::getStoreConfig('multipledeals/configuration/notify')) { $subject = Mage::helper('multipledeals')->__('There are no deals setup at the moment.'); $content = Mage::helper('multipledeals')->__('A customer tried to view the deals page.'); $replyTo = Mage::getStoreConfig('trans_email/ident_general/email', $storeId); $mail = new Zend_Mail(); $mail->setBodyHtml($content); $mail->setFrom($replyTo); $mail->addTo(Mage::getStoreConfig('multipledeals/configuration/admin_email')); $mail->setSubject($subject); $mail->send(); } $this->_redirect('multipledeals/index/list'); } } else { $this->_redirect('no-route'); } }
/** * Enter description here... * */ public function createAction() { $this->requirePost(); $form = $this->getNewResidentForm(); if ($form->isValid($_POST)) { if (!Table_Residents::getInstance()->residentExists($form->getValue('email'))) { $data = $form->getValues(); $password = rand(10000, 9999999); $data['password_hash'] = md5($password); unset($data['aufnehmen']); $newResident = Table_Residents::getInstance()->createRow($data); if ($newResident && $newResident->save()) { $websiteUrl = Zend_Registry::get('configuration')->basepath; $mailText = "Du wurdest in die WG aufgenommen.\n\t\t\t\t\tDu kannst dich nun unter {$websiteUrl}/session/new anmelden.\n\n\t\t\t\t\tDeine Zugangsdaten:\n\n\t\t\t\t\tEmail Addresse = {$newResident->email}\n\t\t\t\t\tPassword = {$password}"; $mail = new Zend_Mail(); $mail->addTo($newResident->email)->setSubject("Du wurdest in der WG aufgenomme!")->setBodyText($mailText); $mail->send(); $this->flash('Der Bewohner mit der Email Addresse ' . $newResident->email . ' wurde erfolgreich eingetragen.'); $this->flash('Ein generiertes Passwort wurde per Email zugeschickt.'); $this->redirect('index'); } else { $this->flash('Es trat ein Fehler beim speichern des neuen Bewohners auf.'); $this->redirect('new'); } } else { $this->flash('Ein Bewohner mit der Emailaddresse ' . $form->getValue('email') . ' existiert bereits.'); $this->redirect('new'); } } else { $this->redirect('new'); } }
public function sendMail() { if (func_num_args() >= 4) { $to = func_get_arg(0); $from = func_get_arg(1); $subject = func_get_arg(2); $messageRecieved = func_get_arg(3); $tr = new Zend_Mail_Transport_Smtp($this->_host, array('auth' => 'login', 'username' => $this->_username, 'password' => $this->_password, 'port' => $this->_port)); Zend_Mail::setDefaultTransport($tr); $mail = new Zend_Mail('utf-8'); $mail->setFrom($from); $mail->setBodyHtml($messageRecieved); $mail->addTo($to); $mail->setSubject($subject); $mail->addHeader('MIME-Version', '1.0'); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader('X-Mailer:', 'PHP/' . phpversion()); try { $mail->send(); $response = "Mail sent"; return $response; } catch (Exception $e) { throw new Zend_Controller_Action_Exception('SendGrid Mail sending error', 500); } } else { throw new Zend_Controller_Action_Exception('Paramter Not passed', 500); } }
/** * @param $store * @param $items * @param $tplSuccess * @param $tplError * @return $this */ public function sendFeedNotification($store, $items, $tplSuccess, $tplError) { $body = ''; $hasError = false; $allowedKeys = array('entity_name', 'store_name', 'error_message'); foreach ($items as $item) { if ($item['successfully']) { $itemMsg = $this->__($tplSuccess); } else { $itemMsg = $this->__($tplError); $hasError = true; } foreach ($allowedKeys as $key) { $value = isset($item[$key]) ? $item[$key] : ''; $itemMsg = str_replace("{{$key}}", $value, $itemMsg); } $body .= $itemMsg . PHP_EOL; } $email = $this->_getConfig()->getNotificationRecipientEmail($store); $subject = $this->_getConfig()->getNotificationSubject(); $subject .= $hasError ? $this->__('Failure') : $this->__('Success'); $mail = new Zend_Mail(); $mail->setFrom($this->_getConfig()->getDefaultSenderEmail(), $this->_getConfig()->getDefaultSenderName()); $mail->addTo($email); $mail->setSubject($subject); $mail->setBodyHtml(nl2br($body)); try { $mail->send(); } catch (Exception $e) { Mage::logException($e); } return $this; }
/** * sends a standard email * * @param string $subject * @param string $toName * @param array $toEmails * @param array $emailOptions * @param string $fromName * @param string $fromEmail */ public function send($subject, $toName, $toEmails = array(), $emailOptions = array(), $fromName = null, $fromEmail = null) { $logger = Zend_Registry::get('logger'); $config = vkNgine_Config::getSystemConfig()->mail; if ($config->serverType == 'smtp') { $tr = new Zend_Mail_Transport_Smtp($config->server, $config->toArray()); } Zend_Mail::setDefaultTransport($tr); foreach ($toEmails as $email) { $mail = new Zend_Mail(); if ($emailOptions['type'] == 'html') { $mail->setBodyHtml($emailOptions['email']); } else { $mail->setBodyText($emailOptions['email']); } if (!$fromName || !$fromEmail) { $mail->setFrom($config->noreply, 'GYM Tracker'); } else { $mail->setFrom($fromEmail, $fromName); } $mail->addTo($email, $toName); $mail->setSubject($subject); try { $mail->send(); } catch (Zend_Mail_Protocol_Exception $e) { $logger->log('MESSAGE_SEND_FAILED', 'Unable to send to ' . $email . ' - ' . $e->getMessage(), 1); } } }
public function sendStatusEmail() { $vBody = ''; $aSuccess = $this->getSuccess(); if (count($aSuccess) > 0) { $vBody .= "The following completed successfully:\n * " . implode("\n * ", $aSuccess) . "\n\n"; } $aErrors = $this->getErrors(); if (count($aErrors) > 0) { $vBody .= "The following errors occurred (feed - sku - error):\n"; foreach ($aErrors as $aError) { $vBody .= $aError['feed'] . ' - ' . $aError['sku'] . ' - ' . $aError['message'] . "\n"; } } if ($vBody !== '') { $aTo = Mage::getStoreConfig(self::CONFIG_EMAIL_TO_ADDRESS); if ($aTo == '') { return $this; } else { $aTo = explode(',', $aTo); } $mail = new Zend_Mail(); $mail->setFrom(Mage::getStoreConfig(self::CONFIG_EMAIL_FROM_ADDRESS), Mage::getStoreConfig(self::CONFIG_EMAIL_FROM_NAME)); $mail->addTo($aTo); $mail->setSubject("Feed Export Status Report"); $mail->setBodyText($vBody); $mail->send(); } }
public function sendEmail($params) { //$smtp = "mail.alquilertop.com"; //"authsmtp.barcelonapordias.com";//"smtp.googlemail.com"; //"mail.carandgo.com"; //"smtp.googlemail.com"; // smtp.googlemail.com //$smtp = "smtp.googlemail.com"; $smtp = "mail.turisdays.com"; //$smtp = "smtp.mail.com"; //$usuario = "*****@*****.**"; //"*****@*****.**";//"*****@*****.**"; //$usuario = "*****@*****.**"; //$usuario = "*****@*****.**"; //$usuario = "*****@*****.**"; $usuario = "*****@*****.**"; //$clave = "0a5g2fxk"; //$clave = "Rtc_728800"; $clave = "728800"; //$de = "*****@*****.**"; //"*****@*****.**";//"*****@*****.**"; //"email"; //$de = "*****@*****.**"; //$de = "*****@*****.**"; $de = "*****@*****.**"; //$asunto = "Interesado en alquiler"; //$mensagem = "<b>Probando servidor de correo barcelonapordias.com </b> Testeo de envio de email !!."; try { $config = array('auth' => 'login', 'username' => $usuario, 'password' => $clave, 'ssl' => 'ssl', 'port' => '465'); $mailTransport = new Zend_Mail_Transport_Smtp($smtp, $config); //die('<pre>' . print_r($mailTransport,true) . '</pre>'); $mail = new Zend_Mail(); $mail->setFrom($de); $mail->addTo($params['para']); $mail->setBodyHtml($params['mensaje']); $mail->setSubject($params['asunto']); $mail->send($mailTransport); } catch (Exception $e) { echo $e->getMessage(); } }
public function init() { $this->model = new ContactUsForm(); if (isset($_POST['ContactUsForm'])) { $this->model->attributes = $_POST['ContactUsForm']; if ($this->model->validate()) { $this->successMessage = 'Your message has been sent, thank you'; try { include_once "Zend/Mail.php"; $contactName = strip_tags($this->model->name); $staffMessage = "Name:\t" . $contactName . "\n" . "Tel:\t" . $this->model->telephone . "\n" . "Email:\t" . $this->model->email . "\n" . "Message:\n" . $this->model->message . "\n\n" . "Sent:\t" . date("d/m/Y H:i"); $mailToStaff = new Zend_Mail("UTF-8"); $mailToStaff->addTo($this->model->to . Yii::app()->params['contactUs']['email_hostname']); $mailToStaff->setFrom($this->model->to . Yii::app()->params['contactUs']['email_hostname']); $mailToStaff->setSubject("Message posted from Wooster & Stock Contact Page"); $mailToStaff->setBodyText($staffMessage); $mailToStaff->send(); $mailToClient = new Zend_Mail('UTF-8'); $mailToClient->addTo($this->model->email, $contactName); $mailToClient->setFrom($this->model->to . Yii::app()->params['contactUs']['email_hostname']); $mailToClient->setSubject("Message posted from Wooster & Stock Contact Page"); $mailToClient->setBodyText($this->emailText('text', $this->model->email, $contactName)); $mailToClient->setBodyHtml($this->emailText('html', $this->model->email, $contactName)); $mailToClient->send(); } catch (Exception $e) { } $this->model->unsetAttributes(); } } }
/** * Set mail options method * * @param string $body Body string * @param array $from Sender emails * @param array $addTo Recipients emails * @param string $subject Subject of the mail */ public static function setMailOptions($body, $from, $addTo, $subject) { if (self::$_mail == null) { self::_setMailObj(); } // Validation Classes: $validMail = new Zend_Validate_EmailAddress(); $validString = new Zend_Validate_StringLength(8); // Validate email body if ($validString->isValid($body)) { self::$_mail->setBodyText($body); } else { throw new Exception(implode($validString->getMessages(), '\\n')); } // Validate sender email if ($validMail->isValid($from)) { $emailFrom = $from; } else { throw new Exception(implode($validMail->getMessages(), '\\n')); } self::$_mail->setFrom($emailFrom); // Validate recipient email if ($validMail->isValid($addTo)) { $emailTo = $addTo; } else { throw new Exception(implode($validMail->getMessages(), '\\n')); } self::$_mail->addTo($emailTo); // Validte subject if ($validString->isValid($subject)) { self::$_mail->setSubject($subject); } else { throw new Exception(implode($validString->getMessages(), '\\n')); } }
public function actionIndex() { require_once 'Zend/Mail.php'; $sql = "SELECT * FROM client where (cli_saleemail = 'yes' or cli_letemail = 'yes') and cli_email != '' and cli_email is not null"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $exclude = []; if (file_exists('luna/exclude')) { $exclude = file('luna/exclude'); } foreach ($data as $client) { if (in_array($client['cli_email'], $exclude)) { $this->log('excluded ' . $client['cli_email']); continue; } try { $mail = new Zend_Mail("UTF-8"); $mail->addTo($client['cli_email']); $mail->setFrom('*****@*****.**'); $mail->setSubject('Win 2 tickets to the Luna Outdoor Cinema'); $mail->setBodyHtml($this->renderFile(Yii::getPathOfAlias('application.commands.luna') . '/template.php', compact('client'), true)); $this->log('Sending mail to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']'); $mail->send(); $this->log('Mail sent to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']'); } catch (Exception $e) { $this->log('ERROR : Mail NOT sent to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']'); } } }
/** * Send an email. * * @param array $params Config object. * Required keys: to, subject, message * Optional keys: replyTo * @param array $viewParams Any values you wish to send to the HTML mail template * @param array $attachments * @return bool */ public function send(array $params, array $viewParams = array(), $attachments = array()) { $this->_validateParams($params); $mail = new Zend_Mail($this->getCharacterEncoding()); $mail->setSubject($params['subject']); $mail->setBodyText($this->_getPlainBodyText($params)); $mail->setFrom($this->getFromAddress(), $this->getFromName()); $mail->addTo($params['to']); $viewParams['subject'] = $params['subject']; if ($this->getHtmlTemplate()) { $viewParams['message'] = isset($params['message']) ? $params['message'] : ''; $viewParams['htmlMessage'] = isset($params['htmlMessage']) ? $params['htmlMessage'] : ''; $mail->setBodyHtml($this->_renderView($viewParams)); } elseif (isset($params['htmlMessage'])) { $mail->setBodyHtml($params['htmlMessage']); } if (!empty($params['replyTo'])) { $mail->setReplyTo($params['replyTo']); } if (!empty($params['cc'])) { $mail->addCc($params['cc']); } if (!empty($params['bcc'])) { $mail->addBcc($params['bcc']); } $this->addAttachments($attachments); $mimeParts = array_map(array($this, '_attachmentToMimePart'), $this->_attachments); array_walk($mimeParts, array($mail, 'addAttachment')); return $mail->send($this->getTransport()); }
public function postAction() { $email = $this->_request->getParam('email'); $response = $this->_helper->response(); if (Kebab_Validation_Email::isValid($email)) { // Create user object $user = Doctrine_Core::getTable('Model_Entity_User')->findOneBy('email', $email); $password = Kebab_Security::createPassword(); if ($user !== false) { $user->password = md5($password); $user->save(); $configParam = Zend_Registry::get('config')->kebab->mail; $smtpServer = $configParam->smtpServer; $config = $configParam->config->toArray(); // Mail phtml $view = new Zend_View(); $view->setScriptPath(APPLICATION_PATH . '/views/mails/'); $view->assign('password', $password); $transport = new Zend_Mail_Transport_Smtp($smtpServer, $config); $mail = new Zend_Mail('UTF-8'); $mail->setFrom($configParam->from, 'Kebab Project'); $mail->addTo($user->email, $user->fullName); $mail->setSubject('Reset Password'); $mail->setBodyHtml($view->render('forgot-password.phtml')); $mail->send($transport); $response->setSuccess(true)->getResponse(); } else { $response->addNotification(Kebab_Notification::ERR, 'There isn\'t user with this email')->getResponse(); } } else { $response->addError('email', 'Invalid email format')->getResponse(); } }
public function indexAction() { do { $message = App_Model_Queue::pop(App_Model_Queue::EMAIL); if ($message) { $user = App_Model_User::fetchOne(['id' => (string) $message->user]); $config = $user->data['mail']; Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($config['server'], ['auth' => $config['auth'], 'username' => $config['username'], 'password' => $config['password'], 'port' => $config['port'], 'ssl' => $config['ssl']])); $mail = new Zend_Mail('UTF-8'); foreach ($message->receivers as $receiver) { $mail->addTo($receiver['email'], $receiver['name']); } $this->writeLine("------------------------------------------------"); $this->writeLine("to: " . print_r($message->receivers, true)); $this->writeLine("from: " . implode(', ', [$user->data['mail']['username'], $user->data['mail']['name']])); $this->writeLine("Subject: " . $message->subject); $mail->setSubject($message->subject); $mail->setBodyHtml($message->content); $mail->setFrom($user->data['mail']['username'], $user->data['mail']['name']); $this->writeLine("Start sending..."); try { $mail->send(); } catch (Exception $e) { $this->writeLine($e->getMessage()); } $this->writeLine('>>>> Done'); sleep(1); } } while (true); }