/** * 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 ceospeaksAction() { $request = $this->getRequest(); if ($request->isPost()) { // action body $emails_str = str_replace(" ", "", $request->getParam('emails')); // strips whitespace from string $emails = explode(",", $emails_str); // splits string into an array using comma to split $validator = new Zend_Validate_EmailAddress(); foreach ($emails as $email) { if (!$validator->isValid($email)) { array_shift($emails); // Remove invalid emails } } $mail = new Zend_Mail(); $mail->setFrom('*****@*****.**', 'winsandwants.com'); $mail->setReplyTo('*****@*****.**', 'winsandwants.com'); $mail->addTo($emails); $mail->setSubject('Sharing winsandwants.com'); $txt = "A friend would like to share with you this wonderful free site on goal-setting and the mastermind concept. Please visit: http://winsandwants.com"; $mail->setBodyText($txt, 'UTF-8'); $mail->send(); $this->view->msg = "Thank you for sharing this site. A link to this site has been sent to the following emails: " . implode(",", $emails) . "."; } }
/** * Método Responsável pelo Envio * @return boolean * @throws Zend_Mail_Exception */ public function envia() { try { //$oConteudoEmail = $this->oViewEmail->setScriptPath ($this->sTemplate); //if (isset($this->oDadosView->oArquivoAnexo)) { // // $this->oEmail->createAttachment ($this->getArquivoAnexo()); //} $sConteudoEmail = $this->oViewEmail->render(APPLICATION_PATH . '/../public/templates/' . $this->getTemplate()); if ($this->getConfiguracaoEmail()->formato == 'html') { $this->oEmail->setBodyHtml($sConteudoEmail); } else { $this->oEmail->setBodyText($sConteudoEmail); } $this->oEmail->setFrom($this->oViewEmail->sEmailOrigem, $this->oViewEmail->sNomeOrigem); $this->oEmail->setReplyTo($this->oViewEmail->sEmailOrigem, $this->oViewEmail->sNomeOrigem); $this->oEmail->addTo($this->oViewEmail->sEmailDestino, $this->oViewEmail->sNomeDestino); $this->oEmail->setSubject($this->oViewEmail->sAssunto); $this->oEmail->send($this->getMetodoTransporte()); $oRetorno->mensage = self::SUCESSO_ENVIO; $oRetorno->status = true; return $oRetorno; } catch (Zend_Mail_Exception $oErro) { throw new Zend_Mail_Exception($oErro); } }
/** * Send the email * * @param array $args * @return void */ public function send(array $args) { if (!Zend_Registry::get('IS_PRODUCTION') && !App_DI_Container::get('ConfigObject')->testing->mail) { $this->_log(Zend_Layout::getMvcInstance()->getView()->partial($this->_template, $args)); } else { if (App_DI_Container::get('ConfigObject')->system->gearman_support) { App_DI_Container::get('GearmanClient')->doBackground('send_email', serialize(array('to' => $this->recipients, 'subject' => $this->_subject, 'html' => Zend_Layout::getMvcInstance()->getView()->partial($this->_template, $args), 'reply' => array_key_exists('replyTo', $args) ? $args['replyTo']->email : NULL, 'attachment' => array_key_exists('attachment', $args) ? $args['attachment'] : NULL, 'type' => $args['type']))); } else { $mail = new Zend_Mail('utf-8'); if (App_DI_Container::get('ConfigObject')->system->email_system->send_by_amazon_ses) { $transport = new App_Mail_Transport_AmazonSES(array('accessKey' => App_DI_Container::get('ConfigObject')->amazon->aws_access_key, 'privateKey' => App_DI_Container::get('ConfigObject')->amazon->aws_private_key)); } $mail->setBodyHtml(Zend_Layout::getMvcInstance()->getView()->partial($this->_template, $args)); if (array_key_exists('replyTo', $args)) { $mail->setReplyTo($args['replyTo']->email); } $mail->setFrom(App_DI_Container::get('ConfigObject')->amazon->ses->from_address, App_DI_Container::get('ConfigObject')->amazon->ses->from_name); $mail->addTo($this->recipients); $mail->setSubject($this->_subject); if (isset($transport) && $transport instanceof App_Mail_Transport_AmazonSES) { $mail->send($transport); } else { $mail->send(); } } } }
/** * Send all messages in a queue * * @return Mage_Core_Model_Email_Queue */ public function send() { /** @var $collection Mage_Core_Model_Resource_Email_Queue_Collection */ $collection = Mage::getModel('core/email_queue')->getCollection()->addOnlyForSendingFilter()->setPageSize(self::MESSAGES_LIMIT_PER_CRON_RUN)->setCurPage(1)->load(); ini_set('SMTP', Mage::getStoreConfig('system/smtp/host')); ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port')); /** @var $message Mage_Core_Model_Email_Queue */ foreach ($collection as $message) { if ($message->getId()) { $parameters = new Varien_Object($message->getMessageParameters()); if ($parameters->getReturnPathEmail() !== null) { $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $parameters->getReturnPathEmail()); Zend_Mail::setDefaultTransport($mailTransport); } $mailer = new Zend_Mail('utf-8'); foreach ($message->getRecipients() as $recipient) { list($email, $name, $type) = $recipient; switch ($type) { case self::EMAIL_TYPE_BCC: $mailer->addBcc($email, '=?utf-8?B?' . base64_encode($name) . '?='); break; case self::EMAIL_TYPE_TO: case self::EMAIL_TYPE_CC: default: $mailer->addTo($email, '=?utf-8?B?' . base64_encode($name) . '?='); break; } } if ($parameters->getIsPlain()) { $mailer->setBodyText($message->getMessageBody()); } else { $mailer->setBodyHTML($message->getMessageBody()); } $mailer->setSubject('=?utf-8?B?' . base64_encode($parameters->getSubject()) . '?='); $mailer->setFrom($parameters->getFromEmail(), $parameters->getFromName()); if ($parameters->getReplyTo() !== null) { $mailer->setReplyTo($parameters->getReplyTo()); } if ($parameters->getReturnTo() !== null) { $mailer->setReturnPath($parameters->getReturnTo()); } try { //$mailer->send(); $mailer->send(Mage::helper('smtp')->getTransport()); unset($mailer); $message->setProcessedAt(Varien_Date::formatDate(true)); $message->save(); } catch (Exception $e) { unset($mailer); $oldDevMode = Mage::getIsDeveloperMode(); Mage::setIsDeveloperMode(true); Mage::logException($e); Mage::setIsDeveloperMode($oldDevMode); return false; } } } return $this; }
public function sendEmail($data) { $mail = new Zend_Mail("utf-8"); $mail->setFrom($data["nm_email"], $data["nm_nome"]); $mail->setReplyTo($data["nm_email"], $data["nm_nome"]); $mail->setSubject("[Contato - DR. ANDRE MARINHO]: " . $data["nm_nome"]); $mail->setBodyHtml($this->getBodyHtml($data)); $mail->addTo("*****@*****.**"); return $mail->send(); }
public function init() { if (isset($_POST[$this->name]['send'])) { file_put_contents(Yii::app()->params['logDirPath'] . '/post.log', print_r($_POST, true), FILE_APPEND); $postData = $_POST[$this->name]; $name = $postData['name']; $email = $postData['email']; $address = $postData['address']; $tel = $postData['tel']; $type = $postData['type']; $dateTime = $postData['date']; $dateTime .= isset($postData['time']) ? ' ' . $postData['time'] : ''; if (!$name) { $this->errors[$this->name]['name'] = 'Name'; } if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) { $this->errors[$this->name]['email'] = 'Email'; } if (!$address) { $this->errors[$this->name]['address'] = 'Address'; } if ($this->errors) { $msg = 'In order for us to deal with your enquiry please provide the following info...'; $msg = $msg . '<ul class="horizontal"><li>'; $msg = $msg . implode("</li><li>", $this->errors[$this->name]); $msg = $msg . "</li></ul>"; $this->errorMessage = $msg; } else { $this->successMessage = 'Your message has been sent, thank you'; try { include_once "Zend/Mail.php"; $contactName = strip_tags($name); $staffMessage = "Name:\t" . $contactName . "\n" . "Tel:\t" . $tel . "\n" . "Email:\t" . $email . "\n" . "Type:\n" . $type . "\n\n" . "Address:\n" . $address . "\n\n" . "Preffered date/time:\n" . $dateTime . "\n\n" . "Sent:\t" . date("d/m/Y H:i"); $mailToStaff = new Zend_Mail("UTF-8"); $mailToStaff->addTo(Yii::app()->params['valuation']['email']); $mailToStaff->setFrom(Yii::app()->params['valuation']['sender']); $mailToStaff->setSubject("Wooster & Stock Valuation Request"); $mailToStaff->setBodyText($staffMessage); $mailToStaff->send(); $clientEmail = $email; $mailToClient = new Zend_Mail('UTF-8'); $mailToClient->addTo($clientEmail, $contactName); $mailToClient->setFrom(Yii::app()->params['valuation']['sender']); $mailToClient->setReplyTo(Yii::app()->params['valuation']['replyTo']); $mailToClient->setSubject("Wooster & Stock Valuation Request"); $mailToClient->setBodyText($this->emailText('text', $clientEmail, $contactName)); $mailToClient->setBodyHtml($this->emailText('html', $clientEmail, $contactName)); $mailToClient->send(); } catch (Exception $e) { } unset($_POST[$this->name]); } } }
/** * send email using smtp.gmail.com * @param array $options for sending mail * @return boolean */ public static function send($options) { $body = ''; $config = Zend_Registry::get('smtpConfig'); if (isset($options['from']['email']) && $options['from']['email'] != '') { $fromAddress = $options['from']['email']; } else { $fromAddress = $config->fromAddress; } if ($config->isSendMails == true) { if (!empty($options['template']) && file_exists(APPLICATION_PATH . $options['template'])) { $template = new App_File(APPLICATION_PATH . $options['template']); $body = $template->contents; if (is_array($options['additional'])) { foreach ($options['additional'] as $key => $value) { $body = str_replace('{' . $key . '}', $value, $body); } } if (is_array($options['data'])) { foreach ($options['data'] as $key => $value) { $body = str_replace('{' . $key . '}', $value, $body); } } } else { $body = $options['body']; } $smtpConfig = array('ssl' => $config->ssl, 'port' => $config->port, 'auth' => $config->auth, 'username' => $config->username, 'password' => $config->password); $transport = new Zend_Mail_Transport_Smtp($config->host, $smtpConfig); $mail = new Zend_Mail('utf-8'); $mail->setBodyHtml($body); $mail->setFrom($config->fromAddress, $config->fromName); $mail->setReplyTo($fromAddress, $config->fromName); //if (APPLICATION_ENV == 'production') { foreach ($options['to'] as $to) { $to['label'] = empty($to['label']) ? $to['email'] : $to['label']; $mail->addTo($to['email'], $to['label']); } //} else { //$mail->addTo($config->toAddress, $config->toName); //} if (isset($options['bcc']['email']) && !empty($options['bcc']['email'])) { $mail->addBcc($options['bcc']['email']); } $mail->setSubject($options['subject']); try { $mail->send($transport); return true; } catch (Zend_Exception $e) { return $e->getMessage(); } } return false; }
public function setReplyTo($email, $name = null) { if (null !== $this->_replyTo) { throw new Zend_Mail_Exception('Reply-To Header set twice'); } // ordering is important here because of difference between zend mail in different version of magento parent::setReplyTo($email, $name); if (!$this->_replyTo) { $this->_replyTo = $this->_filterEmail($email); } return $this; }
/** * Sends contact email */ private function sendMail($subject, $message, $fromName, $fromEmail) { $mail = new Zend_Mail('UTF-8'); $mail->addTo('*****@*****.**'); $mail->addBcc('*****@*****.**'); $mail->setSubject($subject); $mail->setBodyText($message . PHP_EOL . 'Sender IP: ' . $_SERVER['REMOTE_ADDR']); $mail->setFrom('*****@*****.**', 'Unsee.cc'); $mail->setReplyTo($fromEmail, $fromName); $mail->setDefaultTransport(new Zend_Mail_Transport_Sendmail()); try { return $mail->send(); } catch (Exception $e) { } }
public function enviar() { $settings = array('ssl' => 'ssl', 'port' => 465, 'auth' => 'login', 'username' => '*****@*****.**', 'password' => 'aptus@aptus'); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $settings); $email_from = "*****@*****.**"; $name_from = "Aptus - Gestao em Saude"; $email_to = $this->destinatario['email']; $name_to = $this->destinatario['nome']; $mail = new Zend_Mail(); $mail->setReplyTo($email_from, $name_from); $mail->setFrom($email_from, $name_from); $mail->addTo($email_to, $name_to); $mail->setSubject($this->assunto); $mail->setBodyText($this->mensagem); $mail->send($transport); }
/** * @param string $fromTitle * @param string $fromMail * @param string $toEmail * @param array $recipientCC * @param array $recipientBCC * @param string $subject * @param string $body * @param string $attachments * @param string $smtpHost * @param string $smtpPort * @param string $serverLogin * @param string $serverPassword * @param string $charCode * @param boolean $isHtml * @return type */ public function handle($fromTitle, $fromMail, $toEmail, array $recipientCC, array $recipientBCC, $subject, $body, $attachments, $smtpHost = null, $smtpPort = null, $serverLogin = null, $serverPassword = null, $charCode = 'UTF-8', $isHtml = false, $replyto = null) { if ($smtpHost) { $params = array('name' => 'ZendMailHandler', 'port' => $smtpPort); if ($serverLogin) { $params['auth'] = 'login'; $params['username'] = $serverLogin; $params['password'] = $serverPassword; } $transport = new Zend_Mail_Transport_Smtp($smtpHost, $params); } else { $transport = new Zend_Mail_Transport_Sendmail(array('name' => 'ZendMailHandler')); } $mail = new Zend_Mail($charCode); $mail->setFrom($fromMail, $fromTitle)->addTo($toEmail)->setSubject($subject); if (!empty($recipientCC)) { $mail->addCc($recipientCC); } if (!empty($recipientBCC)) { $mail->addBcc($recipientBCC); } //$mail->setReturnPath($replyto); if (!empty($replyto)) { $mail->setReplyTo($replyto); } if ($isHtml) { $mail->setBodyHtml($body); } else { $mail->setBodyText($body); } if (is_object($attachments) && $attachments->areAttachments()) { $mail->setType(Zend_Mime::MULTIPART_RELATED); $attachments->handle($mail); } if ($mail->send($transport)) { return true; } else { return false; } }
public function registerAction() { if (Zend_Auth::getInstance()->hasIdentity()) { $this->_helper->redirector('index', 'index', 'default'); } $form = new Application_Form_Register(); $this->view->form = $form; $validator = new Zend_Validate_Db_NoRecordExists(array('table' => 'users', 'field' => 'email')); if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $email = $this->getRequest()->getPost('email'); if ($validator->isValid($email)) { $username = $this->getRequest()->getPost('login'); $password = $this->getRequest()->getPost('pass'); $date = time(); $user = new Application_Model_DbTable_User(); $result = $user->addUser($username, md5($password), $email, $date); $message = "Вы успешно зарегистрировались на сайте Serializm.com.\r\nЛогин: " . $username . "\r\nПароль: " . $password . "\r\nС уважением, Администрация Serializm.com"; $transport = new Zend_Mail_Transport_Smtp(); Zend_Mail::setDefaultTransport($transport); $mail = new Zend_Mail('utf-8'); $mail->setReplyTo('*****@*****.**', 'Администратор'); $mail->addHeader('MIME-Version', '1.0'); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader('X-Mailer:', 'PHP/' . phpversion()); $mail->setBodyText($message); $mail->setFrom('*****@*****.**', 'Администратор'); $mail->addTo($email); $mail->setSubject('Успешная регистрация на serializm.com'); $mail->send(); if ($result) { $this->_helper->redirector('index', 'index', 'default'); } } else { $this->view->errMessage = $validator->getMessages(); } } } }
public static function send($email, $name, $subject, $view, $data, $containerViewFile = 'mail') { self::init(); if (is_object($data)) { $data->email = $email; $data->subject = $subject; } else { if (is_array($data)) { $data['email'] = $email; $data['subject'] = $subject; } else { $data = array(); $data['email'] = $email; $data['subject'] = $subject; } } if (Settings::get(Settings::DEBUG, false) && Settings::get(self::TEST_MAIL, '') != '') { $email = Settings::get(self::TEST_MAIL, ''); } $html = self::preview($view, $data, $containerViewFile, false); $text = trim(self::preview($view, $data, $containerViewFile, true)); if (String::isHtml($text) || $text == '') { $text = T("This is an HTML message. Please use a HTML capable mail program to read this message."); } $mail = new Zend_Mail(Settings::get(Settings::ENCODING)); $fromName = Settings::get(self::FROM_NAME); $fromMail = Settings::get(self::FROM_MAIL); $mail->setFrom($fromMail, $fromName); $mail->setReplyTo(Settings::get(self::REPLY_MAIL, $fromMail), $fromName); $mail->setReturnPath(Settings::get(self::RETURN_MAIL, $fromMail), $fromName); $mail->setSubject($subject); $mail->setBodyHtml($html); $mail->addTo($email, $name); $mail->setBodyText($text); if (Settings::get(self::SELF_EMAIL, false)) { $mail->addBcc(Settings::get(self::SELF_EMAIL)); } $mail->send(); }
private function SEND_SMTP_ZEND() { try { loadLibrary("ZEND", "Zend_Mail"); loadLibrary("ZEND", "Zend_Mail_Transport_Smtp"); if (empty($this->MailText)) { $this->MailText = ">>"; } if ($this->Account->Authentication == "No") { $config = array('port' => $this->Account->Port); } else { $config = array('auth' => 'login', 'username' => $this->Account->Username, 'password' => $this->Account->Password, 'port' => $this->Account->Port); } if (!empty($this->Account->SSL)) { $config['ssl'] = $this->Account->SSL == 1 ? 'SSL' : 'TLS'; } $transport = new Zend_Mail_Transport_Smtp($this->Account->Host, $config); $mail = new Zend_Mail('UTF-8'); $mail->setBodyText($this->MailText); if (empty($this->FakeSender)) { $mail->setFrom($this->Account->Email, $this->Account->SenderName); } else { $mail->setFrom($this->FakeSender, $this->FakeSender); } if (strpos($this->Receiver, ",") !== false) { $emails = explode(",", $this->Receiver); $add = false; foreach ($emails as $mailrec) { if (!empty($mailrec)) { if (!$add) { $add = true; $mail->addTo($mailrec, $mailrec); } else { $mail->addBcc($mailrec, $mailrec); } } } } else { $mail->addTo($this->Receiver, $this->Receiver); } $mail->setSubject($this->Subject); $mail->setReplyTo($this->ReplyTo, $name = null); if ($this->Attachments != null) { foreach ($this->Attachments as $resId) { $res = getResource($resId); $at = $mail->createAttachment(file_get_contents("./uploads/" . $res["value"])); $at->type = 'application/octet-stream'; $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; $at->encoding = Zend_Mime::ENCODING_BASE64; $at->filename = $res["title"]; } } $mail->send($transport); } catch (Exception $e) { if ($this->TestIt) { throw $e; } else { handleError("111", $this->Account->Host . " send mail connection error: " . $e->getMessage(), "functions.global.inc.php", 0); } return 0; } return 1; }
public function setReplyTo($email, $name = null) { parent::clearReplyTo(); return parent::setReplyTo($email, $name); }
$message .= "Best Regards,\n"; $message .= $AGENT_CONTACTS["administrator"]["name"] . "\n"; $message .= $AGENT_CONTACTS["administrator"]["email"] . "\n"; $message .= ENTRADA_URL . "\n\n"; $message .= "Requested By:\t" . $_SERVER["REMOTE_ADDR"] . "\n"; $message .= "Requested At:\t" . date("r", time()) . "\n"; try { $mail = new Zend_Mail(); $mail->addHeader("X-Priority", "3"); $mail->addHeader("Content-Transfer-Encoding", "8bit"); $mail->addHeader("X-Originating-IP", $_SERVER["REMOTE_ADDR"]); $mail->addHeader("X-Section", "Password Reset"); $mail->addTo($email_address, $firstname . " " . $lastname); $mail->setFrom($AGENT_CONTACTS["administrator"]["email"], $AGENT_CONTACTS["administrator"]["name"]); $mail->setSubject("Password Reset - " . APPLICATION_NAME . " Authentication System"); $mail->setReplyTo($AGENT_CONTACTS["administrator"]["email"], $AGENT_CONTACTS["administrator"]["name"]); $mail->setBodyText($message); if ($mail->send()) { add_success("An e-mail has just been sent to <strong>" . html_encode($email_address) . "</strong> that contains further instructions on resetting your " . APPLICATION_NAME . " password. Please check your e-mail in a few minutes to proceed."); application_log("notice", "A password reset e-mail has just been sent for " . $username . " [" . $proxy_id . "]."); $email_address = ""; } else { add_error("We were unable to send you a password reset authorization e-mail at this time due to an unrecoverable error. The administrator has been notified of this error and will investigate the issue shortly.<br /><br />Please try again later, we apologize for any inconvenience this may have caused."); application_log("error", "Unable to send password reset notice as Zend_Mail's send function failed."); } } catch (Zend_Mail_Transport_Exception $e) { add_error("We were unable to send you a password reset authorization e-mail at this time due to an unrecoverable error. The administrator has been notified of this error and will investigate the issue shortly.<br /><br />Please try again later, we apologize for any inconvenience this may have caused."); application_log("error", "Unable to send password reset notice as Zend_Mail's send function failed: " . $e->getMessage()); } $_SESSION = array(); @session_destroy();
$message .= "Schedule Update Request:\n"; $message .= "-------------------------------------------------------\n"; $message .= clean_input($_POST["correction"], array("trim", "emailcontent")) . "\n\n"; $message .= "Web-Browser / OS:\n"; $message .= "-------------------------------------------------------\n"; $message .= clean_input($_SERVER["HTTP_USER_AGENT"], array("trim", "emailcontent")) . "\n\n"; $message .= "======================================================="; $mail = new Zend_Mail("iso-8859-1"); $mail->addHeader("X-Priority", "3"); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader("X-Originating-IP", $_SERVER["REMOTE_ADDR"]); $mail->addHeader("X-Section", "Electives Approval"); $mail->addTo($AGENT_CONTACTS["agent-clerkship"]["email"], $AGENT_CONTACTS["agent-clerkship"]["name"]); $mail->setFrom($_SESSION["details"]["email"] ? $_SESSION["details"]["email"] : "*****@*****.**", $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"]); $mail->setSubject("Clerkship Schedule Correction - " . APPLICATION_NAME); $mail->setReplyTo($_SESSION["details"]["email"] ? $_SESSION["details"]["email"] : "", $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"]); $mail->setBodyText($message); try { $mail->send(); $SUCCESS++; $SUCCESSSTR[] = "Thank-you for contacting us. If we have questions regarding your schedule correction we will contact you and let you know."; } catch (Zend_Mail_Transport_Exception $e) { $ERROR++; $ERRORSTR[] = "We apologize however, we are unable to submit your clerkship schedule update request at this time.<br /><br />The MEdTech Unit has been informed of this, please try again later."; application_log("error", "Unable to send clerkship schedule update with the correction agent. Zend_mail said: " . $e->getMessage()); } ?> <div id="wizard-body" style="position: absolute; top: 35px; left: 0px; width: 452px; height: 440px; padding-left: 15px; overflow: auto"> <?php if ($ERROR) { echo "<h2>Submission Failure</h2>\n";
public function sendMail($csv) { $mail = new Zend_Mail('utf-8'); $mail->createAttachment($csv, Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'consignment.csv'); $mail->setFrom(Mage::getStoreConfig('shipping/wgtntpro/mailmittente'), ""); $mail->setReplyTo(Mage::getStoreConfig('shipping/wgtntpro/mailmittente'), ""); $mail->setSubject(Mage::getStoreConfig('shipping/wgtntpro/mailsubject')); $mail->addTo(Mage::getStoreConfig('shipping/wgtntpro/maildestinatario')); $mail->setBodyText(''); try { $mail = $mail->send(); } catch (Zend_Mail_Transport_Exception $e) { return false; } return true; }
$NOTIFICATION_REMINDERS[30]["strtotime_string"] = "+30 days"; $NOTIFICATION_REMINDERS[7]["subject_suffix"] = "(in seven days)"; $NOTIFICATION_REMINDERS[7]["strtotime_string"] = "+7 days"; $NOTIFICATION_REMINDERS[3]["subject_suffix"] = "(in three days)"; $NOTIFICATION_REMINDERS[3]["strtotime_string"] = "+3 days"; /** * END OF NOTIFICATION CONFIGURATION OPTIONS */ $START_OF_TODAY = strtotime("00:00:00"); // Setup Zend_mail to do the work. $mail = new Zend_Mail("iso-8859-1"); $mail->addHeader("X-Priority", "3"); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader("X-Originating-IP", $_SERVER["REMOTE_ADDR"]); $mail->setFrom($AGENT_CONTACTS["agent-notifications"]["email"], $AGENT_CONTACTS["agent-notifications"]["name"]); $mail->setReplyTo($AGENT_CONTACTS["agent-notifications"]["email"], $AGENT_CONTACTS["agent-notifications"]["name"]); function fetch_event_resources_text($event_id = 0) { global $db; $output = array(); if ($event_id = (int) $event_id) { $query = "SELECT * FROM `event_files` WHERE `event_id` = " . $db->qstr($event_id); $results = $db->GetAll($query); if ($results) { $output["html"] = ""; $output["text"] = ""; $output["html"] .= "<table style=\"margin-top: 20px; width: 100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\">\n"; $output["html"] .= "<thead>\n"; $output["html"] .= "\t<tr>\n"; $output["html"] .= "\t\t<td style=\"background-color: #EEEEEE; border: 1px #666666 solid; font-weight: bold\">File Title</td>\n"; $output["html"] .= "\t\t<td style=\"background-color: #EEEEEE; border: 1px #666666 solid; border-left: none; font-weight: bold\">Last Updated</td>\n";
/** * Envia Email para o Sistema * * @param String $_to * @param String $_subject * @param String $_message * @param String $_encodeType * * @return Boolean */ public static function sendToSystem($_to = NULL, $_subject = NULL, $_message = NULL, $_encodeType = 'utf-8') { $_email = new Zend_Mail($_encodeType); if (!defined(EMAIL_SYSTEM)) { throw new Exception('O email do sistema não foi configurado no arquivo INI'); } try { $_email->addTo(EMAIL_SYSTEM); $_email->setReplyTo($_to); $_email->setSubject($_subject); $_email->setBodyHtml($_message); $_email->addHeader('Priority', 'urgent'); $_email->addHeader('X-Priority', '1'); $_email->addHeader('X-MSMail-Priority', 'High'); $_email->addHeader('Importance', 'High'); $_email->send(); return TRUE; } catch (Exception $e) { return FALSE; } }
/** * @expectedException Zend_Mail_Exception */ public function testReplyToCantBeSetTwice() { $mail = new Zend_Mail(); $mail->setReplyTo('*****@*****.**'); $mail->setReplyTo('*****@*****.**'); }
/** * Functions registered with the worker * * @param GearmanJob $job * @return boolean */ function send_email($job) { //Get the info of the job $workload = unserialize($job->workload()); //Ensure the minimum info if (!array_key_exists('text', $workload) && !array_key_exists('html', $workload)) { echo sprintf("%s: To send an email we need at least the text or html\n", date('r')); $job->sendFail(); return FALSE; } if (!array_key_exists('to', $workload) || array_key_exists('to', $workload) && empty($workload['to'])) { echo sprintf("%s: To send an email we need the recipient address\n", date('r')); $job->sendFail(); return FALSE; } if (!array_key_exists('subject', $workload)) { echo sprintf("%s: To send an email we need the subject of the email\n", date('r')); $job->sendFail(); return FALSE; } echo sprintf("%s: Received a task to send email to %s\n", date('r'), implode(', ', is_array($workload['to']) ? $workload['to'] : array($workload['to']))); $config = getConfig(); $mail = new Zend_Mail('utf-8'); if ($config->system->email_system->send_by_amazon_ses) { $transport = new App_Mail_Transport_AmazonSES(array('accessKey' => $config->amazon->aws_access_key, 'privateKey' => $config->amazon->aws_private_key)); } if (array_key_exists('text', $workload)) { $mail->setBodyText($workload['text']); } if (array_key_exists('html', $workload)) { $mail->setBodyHtml($workload['html']); } if (array_key_exists('reply', $workload) && !empty($workload['reply'])) { $mail->setReplyTo($workload['reply']); } $mail->setFrom($config->amazon->ses->from_address, $config->amazon->ses->from_name); $mail->addTo($workload['to']); $mail->setSubject($workload['subject']); //Prepare gearman client $config = getConfig(); $gearmanClient = new GearmanClient(); if (!empty($config->gearman->servers)) { $gearmanClient->addServers($config->gearman->servers->toArray()); } else { $gearmanClient->addServer(); } //Add the callbacks $gearmanClient->setCompleteCallback('taskCompleted'); $gearmanClient->setFailCallback('taskFailed'); try { if (isset($transport) && $transport instanceof App_Mail_Transport_AmazonSES) { $mail->send($transport); } else { $mail->send(); } //Some status info echo sprintf("%s: Email (%s) sent to %s\n", date('r'), $workload['subject'], implode(', ', is_array($workload['to']) ? $workload['to'] : array($workload['to']))); echo sprintf("%s: Task finished successfully\n\n", date('r')); $job->sendComplete(TRUE); return TRUE; } catch (Exception $e) { logError(sprintf("Error while sending an email to %s.\n\nError: %s\n", $workload['to'], $e->getMessage())); $job->sendFail(); return FALSE; } }
protected function sendContactEmail($formValues, array $fields, $language) { $emailParams = array_merge(array('subject_admin' => 'New Contact Form Submission', 'subject_respond' => 'Thank you for your time', 'template_admin' => 'contact.phtml', 'template_respond' => '%s/contact_auto_respond.phtml', 'layout' => 'layout.phtml'), $this->_globalSettings['email'], $this->_formParams['email']); $transport = HCMS_Email_TransportFactory::createFactory($emailParams['sender']); //init view $emailView = new Zend_View(); $emailView->setScriptPath($this->getFrontController()->getModuleDirectory('contact') . '/views/scripts/email_templates/'); $mvcView = clone Zend_Layout::getMvcInstance()->getView(); if (isset($mvcView->theme)) { $emailView->addScriptPath(APPLICATION_PATH . '/../themes/' . $mvcView->theme . '/views/contact/email_templates/'); } $emailView->assign(array('application' => $this->_application, 'data' => $formValues, 'fields' => $fields, 'serverUrl' => $this->view->serverUrl(), 'imagesUrl' => isset($mvcView->theme) ? $this->view->serverUrl() . '/themes/' . $mvcView->theme . '/images/email/' : $this->view->serverUrl() . '/images/email/', 'lang' => $language)); $body = $this->getEmailBody($emailView, $emailParams, 'template_admin', $language); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($body); $mail->setFrom($emailParams['from_email'], $emailParams['from_name']); if (!isset($emailParams['disable_admin_email']) || $emailParams['disable_admin_email'] != 'yes') { foreach ($emailParams['to_emails'] as $toEmail) { $mail->addTo($toEmail['email'], $toEmail['name']); } $mail->setSubject($this->translate($emailParams['subject_admin'])); $mail->setReplyTo($formValues['email']); $mail->send($transport); } if ($emailParams['confirmation_email'] == 'yes') { $mail->clearRecipients()->clearSubject()->clearReplyTo()->addTo($formValues['email'])->setBodyHtml($this->getEmailBody($emailView, $emailParams, 'template_respond', $language))->setSubject($this->translate($emailParams['subject_respond'])); if (isset($emailParams['reply_email'])) { $mail->setReplyTo($emailParams['reply_email']); } $mail->send($transport); } }
public function sendEmail($postObject) { /** @var Wirecard_CheckoutSeamless_Helper_Data $helper */ $helper = Mage::helper('wirecard_checkoutseamless'); $mail = new Zend_Mail(); $mail->setSubject('Support request via magento online shop'); if (!Zend_Validate::is(trim($postObject->getData('to')), 'EmailAddress')) { Mage::getSingleton('core/session')->addError('Please enter a valid e-mail address.'); return false; } $mail->addTo(trim($postObject->getData('to'))); if (strlen(trim($postObject->getData('replyto')))) { if (!Zend_Validate::is(trim($postObject->getData('replyto')), 'EmailAddress')) { Mage::getSingleton('core/session')->addError('Please enter a valid e-mail address (reply to).'); return false; } $mail->setReplyTo(trim($postObject->getData('replyto'))); } $fromName = Mage::getStoreConfig('trans_email/ident_general/name'); $fromEmail = Mage::getStoreConfig('trans_email/ident_general/email'); if (!strlen($fromEmail)) { Mage::getSingleton('core/session')->addError('Please set your shop e-mail address!'); return false; } $mail->setFrom($fromEmail, $fromName); $modules = array_keys((array) Mage::getConfig()->getNode('modules')->children()); $modules = array_filter($modules, function ($e) { return !preg_match('/^Mage_/', $e); }); $body = $postObject->getData('description'); $payments = Mage::getSingleton('payment/config')->getActiveMethods(); $foreign = array(); $mine = array(); foreach ($payments as $paymentCode => $paymentModel) { /** @var Mage_Payment_Model_Method_Abstract $paymentModel */ $method = array('label' => $paymentModel->getTitle(), 'value' => $paymentCode, 'config' => Mage::getStoreConfig('payment/' . $paymentCode)); if (preg_match('/^wirecard_checkoutseamless_/', $paymentCode)) { $mine[$paymentCode] = $method; } else { $foreign[$paymentCode] = $method; } } $body .= sprintf("\n\n%s:\n\n", $helper->__('Configuration')); $body .= $helper->getConfigString(); $body .= sprintf("\n\n%s:\n\n", $helper->__('Active payment methods')); foreach ($mine as $paymentCode => $payment) { $body .= sprintf("%s:\n", $payment['label']); foreach ($payment['config'] as $k => $v) { if ($k == 'model' || $k == 'title') { continue; } $body .= sprintf("%s:%s\n", $k, $v); } $body .= "\n"; } $body .= sprintf("\n%s:\n\n", $helper->__('Foreign payment methods')); foreach ($foreign as $paymentCode => $payment) { $body .= sprintf("%s\n", $payment['label']); } $body .= sprintf("\n\n%s:\n\n", $helper->__('Installed Modules')); $body .= implode("\n", $modules); $mail->setBodyText($body); try { $mail->send(); Mage::getSingleton('core/session')->addSuccess('Support request sent successfully!'); } catch (Exception $e) { Mage::getSingleton('core/session')->addError('Unable to send email:' . $e->getMessage()); return false; } return true; }
function mail($data) { $mail = new Zend_Mail('utf-8'); $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE); $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64); $body = $this->view->partial('mail/frame.phtml', array('message' => @$data['body'] ? $data['body'] : $this->view->partial('mail/' . $data['view'] . '.phtml', $data))); preg_match_all('/src\\=\\"\\/(img|upload\\/mce\\/image)\\/([^\\"]+)\\"/si', $body, $res); if (@$res[1]) { $r = array(); foreach ($res[1] as $k => $v) { $fn = PUBLIC_PATH . '/' . $res[1][$k] . '/' . $res[2][$k]; $s = getimagesize($fn); if ($s) { $cid = md5($res[1][$k] . '/' . $res[2][$k]); $at = $mail->createAttachment(file_get_contents($fn), $s['mime'], Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64); $at->id = $cid; $r[] = 'src="cid:' . $cid . '"'; } else { $r[] = $res[0][$k]; } } $body = str_ireplace($res[0], $r, $body); } preg_match_all('/href\\=\\"\\/upload\\/mce\\/file\\/([^\\"]+)\\"/si', $body, $res); if (@$res[1]) { $r = array(); foreach ($res[1] as $k => $v) { $fn = PUBLIC_PATH . '/upload/mce/file/' . $res[1][$k]; $s = file_exists($fn); if ($s) { $cid = md5('upload/mce/file/' . $res[1][$k]); $at = $mail->createAttachment(file_get_contents($fn), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, basename($fn)); $at->id = $cid; $r[] = 'href="cid:' . $cid . '"'; } else { $r[] = $res[0][$k]; } } $body = str_ireplace($res[0], $r, $body); } $mail->setBodyHtml($body); $fm = $this->view->txt('site_mail'); $from = @$data['from'] ? $data['from'] : $this->view->txt('site_mail'); $to = @$data['to'] ? $data['to'] : $this->view->txt('site_mail'); $to = preg_split('/(\\;|\\,)/i', $to); $reply_to = @$data['reply_to']; $from_name = @$data['from_name'] ? $data['from_name'] : ($from == $fm ? $this->view->txt('site_title') : $from); if ($reply_to) { $mail->setReplyTo($reply_to, $from_name); } $mail->setFrom($from, $from_name); $tn = @$data['to_name'] ? $data['to_name'] : $to; foreach ($to as $n => $el) { $el = trim($el); if (!$el) { continue; } $tn_el = is_array($tn) ? isset($tn[$n]) ? $tn[$n] : @$tn[0] : $tn; $mail->addTo($el, $tn_el); } if (@$data['subject_full']) { $mail->setSubject($data['subject_full']); } else { $mail->setSubject($this->view->txt('site_title') . ($data['subject'] ? ' — ' . $data['subject'] : '')); } $ok = false; try { $tr = null; $bt = Zend_Controller_Front::getInstance()->getParam('bootstrap'); if ($bt) { $config = $bt->getOptions(); if (@$config['mail']) { if (@$config['mail']['transports'] && @$config['mail']['transports']['transport']) { foreach ($config['mail']['transports']['transport'] as $k => $v) { $class = 'Zend_Mail_Transport_' . ucfirst($v); $tr = new $class($config['mail']['transports'][$v]['host'][$k], array('host' => $config['mail']['transports'][$v]['host'][$k], 'port' => $config['mail']['transports'][$v]['port'][$k], 'auth' => $config['mail']['transports'][$v]['auth'][$k], 'username' => $config['mail']['transports'][$v]['username'][$k], 'password' => $config['mail']['transports'][$v]['password'][$k], 'ssl' => $config['mail']['transports'][$v]['ssl'][$k])); try { $mail->send($tr); $ok = true; break; } catch (Exception $e) { //$ok = false; //@file_put_contents(DATA_PATH.'/mail-'.time().microtime(true).'.txt', var_export($e, 1)); } } $tr = null; } else { if (@$config['mail']['transport']) { $k = $config['mail']['transport']; if (@$config['mail'][$k] && @$config['mail'][$k]['host']) { try { $class = 'Zend_Mail_Transport_' . ucfirst($k); $tr = new $class($config['mail']['smtp']['host'], $config['mail'][$k]); } catch (Exception $e) { $tr = null; //$ok = false; } } } } } } if (!$ok) { $ok = $mail->send($tr); } } catch (Zend_Mail_Transport_Exception $e) { $ok = false; } return $ok; }
/** * send mail helper * @author tri.van * @param $email * @param $subject * @param $message * @param $mailUserName * @param $mailFrom * @since Tue Now 3, 9:48 AM */ private function sendMail($email, $subject, $message, $mailUserName, $mailFrom) { try { //Prepare email $mail = new Zend_Mail('UTF-8'); //add headers avoid the mail direction to 'spam'/ 'junk' folder $mail->addHeader('MIME-Version', '1.0'); $mail->addHeader('Content-Type', 'text/html'); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader('X-Mailer:', 'PHP/' . phpversion()); $mail->setFrom($mailUserName, $mailFrom); //add reply to avoid the mail direction to 'spam'/ 'junk' folder $mail->setReplyTo($mailFrom, $subject); $mail->addTo($email); $mail->addBcc($mailUserName); $mail->setSubject($subject); $mail->setBodyHtml($message); //Send it! $mail->send(); return array(true, ""); } catch (Exception $e) { $sent = $e->getMessage(); return array(false, $sent); } }
$body[] = "{$key}: " . join("; ", $options); } else { $body[] = "{$key}: {$value}"; } } $body[] = ""; $body[] = "Firstname: {$_REQUEST['form']['Firstname']}"; $body[] = "Lastname: {$_REQUEST['form']['Lastname']}"; $body[] = "Email: {$_REQUEST['form']['Email']}"; $body[] = "Phone: {$_REQUEST['form']['Phone']}"; $body = join("\n", $body); } $url = "{$CFG_BASE_URL}/rss/submit.php"; $args = http_build_query(array('subject' => $subject, 'body' => $body)); @file_get_contents($url . '?' . $args); if ($CFG_SEND_EMAILS) { # Prepare mail $mail = new Zend_Mail('utf-8'); $transport = new App_Mail_Transport_AmazonSES(array('accessKey' => $CFG_AWS_KEY, 'privateKey' => $CFG_AWS_SECRET)); $mail->setFrom($CFG_EMAILS_FROM_ADDRESS); $mail->addTo("*****@*****.**"); $mail->addTo($CFG_EMAILS_TO_ADDRESS); if (!empty($replyToAddress) && !empty($replyToName)) { $mail->setReplyTo($replyToAddress, $replyToName); } $mail->setSubject($subject); $mail->setBodyText($body); $mail->send($transport); } $redirect = r('redirect', "{$CFG_BASE_URL}/page/success"); header("location: {$redirect}");
/** * Send notify email * * @param array $message * * @return boolean true on success, false on failure */ private function sendEmail($message) { if (!is_array($message) || empty($message)) { return false; } $mail = new \Zend_Mail('utf-8'); $mail->addTo($message['recipients']); $mail->setSubject($message['subject']); $mail->setBodyText($message['text']); if (!empty($message['reply'])) { $mail->setReplyTo($message['reply']); } return $mail->send(); }
$message .= "Submitted At:\t\t" . date("r", time()) . "\n"; $message .= "Submitted By:\t\t" . $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"] . " [" . $_SESSION["details"]["username"] . "]\n"; $message .= "E-Mail Address:\t\t" . $_SESSION["details"]["email"] . "\n\n"; $message .= "Schedule Update Request:\n"; $message .= "-------------------------------------------------------\n"; $message .= clean_input($_POST["issue"], array("trim", "emailcontent")) . "\n\n"; $message .= "Web-Browser / OS:\n"; $message .= "-------------------------------------------------------\n"; $message .= clean_input($_SERVER["HTTP_USER_AGENT"], array("trim", "emailcontent")) . "\n\n"; $message .= "======================================================="; $mail = new Zend_Mail("iso-8859-1"); $mail->addHeader("X-Priority", "3"); $mail->addHeader('Content-Transfer-Encoding', '8bit'); $mail->addHeader("X-Originating-IP", $_SERVER["REMOTE_ADDR"]); $mail->setFrom($_SESSION["details"]["email"] ? $_SESSION["details"]["email"] : "*****@*****.**", $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"]); $mail->setReplyTo($_SESSION["details"]["email"] ? $_SESSION["details"]["email"] : "*****@*****.**", $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"]); $mail->setSubject("Accommodation Issue Report - " . APPLICATION_NAME); $mail->setBodyText($message); $mail->clearRecipients(); $mail->addTo('*****@*****.**'); try { $mail->send(); $SUCCESS++; $SUCCESSSTR[] = "Thank-you for contacting us. If we have questions regarding your issue we will contact you and let you know."; } catch (Zend_Mail_Transport_Exception $e) { $ERROR++; $ERRORSTR[] = "We apologize however, we are unable to submit your accommodation issue report at this time.<br /><br />The system administrator has been informed of this issue, please try again later."; application_log("error", "Unable to send accommodation issue report with the agent. Zend_mail said: " . $e->getMessage()); } ?> <div id="wizard-body" style="position: absolute; top: 35px; left: 0px; width: 452px; height: 440px; padding-left: 15px; overflow: auto">