本文整理汇总了PHP中Zend_Mail::addTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail::addTo方法的具体用法?PHP Zend_Mail::addTo怎么用?PHP Zend_Mail::addTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Mail
的用法示例。
在下文中一共展示了Zend_Mail::addTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveFiles
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;
}
示例2: forgotPassword
/**
* @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();
}
}
示例3: sendMessage
/**
* @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;
}
示例4: _sendNewCommentEmail
/**
* 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);
}
示例5: sendEmail
/**
* 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];
}
示例6: send
/**
* Odesle E-mail
*
* @param string $recipient E-mail prijemce
*/
public function send($recipient)
{
$smtpOptions = array('auth' => 'login', 'username' => 'mybase.unodor@gmail.com', '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);
}
示例7: notifyCustomerOfDelivery
/**
* 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('orders@chrisweldon.net', '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();
}
示例8: postInsert
/**
* 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();
}
示例9: 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());
}
}
示例10: __construct
/**
*
* @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);
}
}
示例11: send
/**
* 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);
}
示例12: sendMail
/**
* 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();
}
示例13: getMail
/**
* @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;
}
示例14: contatoAction
public function contatoAction()
{
if ($this->_request->isPost()) {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/default/layouts/scripts/');
$title = 'Contato | Instag';
$to = 'eduardo@inndeia.com';
$cc = 'renato@inndeia.com';
$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' => 'nao-responder@instag.com.br', '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');
}
}
示例15: runTest
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;
}