public function sendMail(Zend_Mail $mail, $body, $header) { $this->mail = $mail; $this->body = $body; $this->header = $header; $this->recipients = $mail->getRecipients(); $this->subject = $mail->getSubject(); $this->from = $mail->getFrom(); $this->called = true; }
/** * Send a mail using this transport * * @return void * @throws \Magento\Framework\Exception\MailException */ public function sendMessage() { try { $sendpulseClient = null; $recipients = implode(',', $this->_message->getRecipients()); $parameters = array('from' => $this->_message->getFrom(), 'to' => $recipients, 'subject' => quoted_printable_decode($this->_message->getSubject()), 'text' => quoted_printable_decode($this->_message->getBodyText(true)), 'html' => quoted_printable_decode($this->_message->getBodyHtml(true))); // TODO add attachment support $attachments = array(); /* $attachments = array( 'attachment' => array( '/path/to/file.txt', '/path/to/file.txt' ) ); */ # Make the call to the client. $result = $sendpulseClient->sendMessage($this->_config->getMailgunDomain(), $parameters, $attachments); } catch (\Exception $e) { throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e); } }
/** * Send a mail using this transport * * @return void * @throws \Magento\Framework\Exception\MailException */ public function sendMessage() { try { /** @var Client $client */ $client = new Client(); /** @var $mailgunClient Mailgun */ $mailgunClient = new Mailgun($this->_config->getMailgunKey(), $client); /** @var string $recipients comma separated */ $recipients = implode(',', $this->_message->getRecipients()); // Assign default parameters $parameters = array('from' => $this->_message->getFrom(), 'to' => $recipients, 'subject' => $this->decodeZendQuotedPrintableHeader($this->_message->getSubject()), 'text' => quoted_printable_decode($this->_message->getBodyText(true)), 'html' => quoted_printable_decode($this->_message->getBodyHtml(true))); $parameters = $this->assignOptionalParameters($parameters); /** @var array $postFiles */ $postFiles = $this->getPostFiles(); $domain = $this->_config->getMailgunDomain(); $result = $mailgunClient->sendMessage($domain, $parameters, $postFiles); $this->getMail()->setResult($result); $this->getMail()->setSent($this->createSent())->setSentAt($this->createSentAt())->setTransportId($this->createTransportId()); } catch (\Exception $e) { throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e); } }
public function testReturnPath() { $mail = new Zend_Mail(); $res = $mail->setBodyText('This is a test.'); $mail->setFrom('*****@*****.**', 'test Mail User'); $mail->setSubject('My Subject'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addBcc('*****@*****.**'); $mail->addBcc('*****@*****.**'); $mail->addCc('*****@*****.**', 'Example no. 1 for cc'); $mail->addCc('*****@*****.**', 'Example no. 2 for cc'); // First example: from and return-path should be equal $mock = new Zend_Mail_Transport_Mock(); $mail->send($mock); $this->assertTrue($mock->called); $this->assertEquals($mail->getFrom(), $mock->returnPath); // Second example: from and return-path should not be equal $mail->setReturnPath('*****@*****.**'); $mock = new Zend_Mail_Transport_Mock(); $mail->send($mock); $this->assertTrue($mock->called); $this->assertNotEquals($mail->getFrom(), $mock->returnPath); $this->assertEquals($mail->getReturnPath(), $mock->returnPath); $this->assertNotEquals($mock->returnPath, $mock->from); }
public function sendRaw(Zend_Mail $mail) { if ($this->_enabled) { try { $mail->send($this->getTransport()); } catch (Exception $e) { // Silence? Note: Engine_Exception 's are already logged if (!$e instanceof Engine_Exception && Zend_Registry::isRegistered('Zend_Log')) { $log = Zend_Registry::get('Zend_Log'); $log->log($e, Zend_Log::ERR); } } // Logging in dev mode if ('development' == APPLICATION_ENV) { $this->getLog()->log(sprintf('[%s] %s <- %s', 'Zend', join(', ', $mail->getRecipients()), $mail->getFrom()), Zend_Log::DEBUG); } // Track emails Engine_Api::_()->getDbtable('statistics', 'core')->increment('core.emails'); } return $this; }
public function testSettingFromDefaults() { Zend_Mail::setDefaultFrom('*****@*****.**', 'John Doe'); Zend_Mail::setDefaultReplyTo('*****@*****.**', 'Foo Bar'); $mail = new Zend_Mail(); $headers = $mail->setFromToDefaultFrom()->setReplyToFromDefault()->getHeaders(); $this->assertEquals('*****@*****.**', $mail->getFrom()); $this->assertEquals('*****@*****.**', $mail->getReplyTo()); $this->assertEquals('John Doe <*****@*****.**>', $headers['From'][0]); $this->assertEquals('Foo Bar <*****@*****.**>', $headers['Reply-To'][0]); }
/** * send an email * * @param Zend_Mail $mail * @param string $body * @param string $headers */ public function sendMail(Zend_Mail $mail, $body, $headers) { $wasConnected = $this->_con !== null; // check if the connection is already there if (!$wasConnected) { $this->connect(); } else { $this->rset(); } // if already connected, reset connection try { $this->mail_from($mail->getFrom()); foreach ($mail->getRecipients() as $recipient) { $this->rcpt_to($recipient); } $this->data($headers . "\r\n" . $body); } catch (Zend_Mail_Transport_Exception $e) { if (!$wasConnected) { $this->disconnect(); } // remove connection if we made one throw $e; } if (!$wasConnected) { $this->disconnect(); } // remove connection if we made one }
$message .= "Web-Browser / OS:\n"; $message .= "-------------------------------------------------------\n"; $message .= clean_input($_SERVER["HTTP_USER_AGENT"], array("trim", "emailcontent")) . "\n\n"; $message .= "URL Sent From:\n"; $message .= "-------------------------------------------------------\n"; $message .= (isset($_SERVER["HTTPS"]) ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . clean_input($extracted_information["url"], 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", "Feedback System"); $mail->addTo($AGENT_CONTACTS["annualreport-support"]["email"], $AGENT_CONTACTS["annualreport-support"]["name"]); $mail->setFrom($_SESSION["details"]["email"] ? $_SESSION["details"]["email"] : $AGENT_CONTACTS["administrator"]["email"], $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"]); $mail->setSubject("Report Missing /Incorrect Teaching Submission - " . APPLICATION_NAME); $mail->setReplyTo($mail->getFrom(), $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"]); $mail->setBodyText($message); try { $mail->send(); $SUCCESS++; $SUCCESSSTR[] = "Thank-you for informing us of the missing / incorrect undergraduate teaching. If we have questions regarding any of the information you provided, we will get in touch with you via e-mail, otherwise the teaching will be adjusted within two business days."; } catch (Zend_Mail_Transport_Exception $e) { $ERROR++; $ERRORSTR[] = "We apologize however, we are unable to submit your feedback at this time due to a problem with the mail server.<br /><br />The system administrator has been informed of this error, please try again later."; application_log("error", "Unable to report missing / incorrect undergraduate teaching with the feedback 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>Feedback Submission Failure</h2>\n";