本文整理汇总了PHP中Zend_Mail::setBodyText方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail::setBodyText方法的具体用法?PHP Zend_Mail::setBodyText怎么用?PHP Zend_Mail::setBodyText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Mail
的用法示例。
在下文中一共展示了Zend_Mail::setBodyText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: recoverAction
public function recoverAction()
{
$request = $this->getRequest();
$registry = Zend_Registry::getInstance();
$auth = Zend_Auth::getInstance();
$config = $registry->get('config');
if ($auth->hasIdentity()) {
$registry->set("pleaseSignout", true);
return $this->_forward("index", "logout");
}
$people = Ml_Model_People::getInstance();
$recover = Ml_Model_Recover::getInstance();
$form = $recover->form();
if ($request->isPost() && $form->isValid($request->getPost())) {
$find = $form->getValues();
//AccountRecover.php validator pass this data: not very hortodox
$getUser = $registry->accountRecover;
$securityCode = $recover->newCase($getUser['id']);
$this->view->securitycode = $securityCode;
$this->view->recoverUser = $getUser;
$this->view->recovering = true;
$mail = new Zend_Mail();
$mail->setBodyText($this->view->render("password/emailRecover.phtml"))->setFrom($config['robotEmail']['addr'], $config['robotEmail']['name'])->addTo($getUser['email'], $getUser['name'])->setSubject('Recover your ' . $config['applicationname'] . ' account')->send();
}
$this->view->recoverForm = $form;
}
示例4: sendStatusEmail
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();
}
}
示例5: send
public function send()
{
$_helper = Mage::helper('smtppro');
// If it's not enabled, just return the parent result.
if (!$_helper->isEnabled()) {
return parent::send();
}
if (Mage::getStoreConfigFlag('system/smtp/disable')) {
return $this;
}
$mail = new Zend_Mail();
if (strtolower($this->getType()) == 'html') {
$mail->setBodyHtml($this->getBody());
} else {
$mail->setBodyText($this->getBody());
}
$mail->setFrom($this->getFromEmail(), $this->getFromName())->addTo($this->getToEmail(), $this->getToName())->setSubject($this->getSubject());
$transport = new Varien_Object();
// for observers to set if required
Mage::dispatchEvent('aschroder_smtppro_before_send', array('mail' => $mail, 'email' => $this, 'transport' => $transport));
if ($transport->getTransport()) {
// if set by an observer, use it
$mail->send($transport->getTransport());
} else {
$mail->send();
}
Mage::dispatchEvent('aschroder_smtppro_after_send', array('to' => $this->getToName(), 'subject' => $this->getSubject(), 'template' => "n/a", 'html' => strtolower($this->getType()) == 'html', 'email_body' => $this->getBody()));
return $this;
}
示例6: 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;
}
示例7: testSendMail
public function testSendMail()
{
$mail = new Zend_Mail();
$mail->setBodyText('This mail should never be sent.');
$mailTransport = new Centurion_Mail_Transport_Blackhole();
$mailTransport->send($mail);
}
示例8: setMailOptions
/**
* 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'));
}
}
示例9: 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;
}
示例10: sendAction
public function sendAction()
{
// 返回值数组
$result = array();
// 请求参数
// $request = $this->getRequest()->getParams();
$now = date('Y-m-d H:i:s');
/* $data = array(
'subject' => $request['subject'],
'to' => $request['to'],
'to_name' => $request['to_name'],
'cc' => $request['cc'],
'cc_name' => $request['cc_name'],
'content' => $request['content'],
'attachment' => $request['attachment']
); */
$data = array('subject' => 'test', 'to' => '14706931@qq.com', 'to_name' => '新大陆', 'cc' => 'leonli188@126.com', 'cc_name' => 'leon', 'content' => 'test123测试', 'charset' => 'utf-8', 'attachment' => null);
echo '<pre>';
print_r($data);
$mailConfig = new Zend_Config_Ini(CONFIGS_PATH . '/application.ini', 'mail');
$from = $mailConfig->smtp->from;
$fromname = $mailConfig->smtp->fromname;
$transport = new Zend_Mail_Transport_Smtp($mailConfig->smtp->server, $mailConfig->smtp->params->toArray());
$mail = new Zend_Mail();
$mail->setSubject($data['subject']);
$mail->setBodyText($data['content'], $data['charset']);
$mail->setFrom($from, $fromname);
$mail->addTo($data['to'], $data['to_name']);
$mail->addCc($data['cc'], $data['cc_name']);
$mail->addAttachment('MailController.php');
$mail->createAttachment(file_get_contents('E:\\sina.png'), 'image/png', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, 'sina.png');
print_r($mail->send($transport));
//echo Zend_Json::encode($result);
exit;
}
示例11: 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();
}
}
示例12: send
public function send()
{
$bodyMessage = "MENSAGEM:\n \n\t\t" . $this->_contactMail->getMessage() . "\n\n\t\tNOME DO CONTATO: " . $this->_contactMail->getName() . "\n\t\tE-MAIL PARA RESPOSTA: " . $this->_contactMail->getFrom() . "\n\n\t\tIP:{$_SERVER['REMOTE_ADDR']}";
/*
* send the email
*/
try {
$mail = new Zend_Mail();
$mail->setBodyText($bodyMessage);
$mail->setFrom($this->_contactMail->getFrom(), $this->_contactMail->getName());
$mail->addTo($this->_contactMail->getTo());
$mail->setSubject($this->_contactMail->getSubject());
$mail->send();
// To sender
// TODO internacionalization
$bodyMessage = "Sua mensagem enviada como contato para " . $this->_contactMail->getTo() . ":\n " . $bodyMessage;
$mail = new Zend_Mail();
$mail->setBodyText($bodyMessage);
$mail->setFrom($this->_contactMail->getFrom(), $this->_contactMail->getName());
$mail->addTo($this->_contactMail->getFrom());
$mail->setSubject($this->_contactMail->getSubject());
$mail->send();
return true;
} catch (Exception $e) {
throw new Zend_Exception("Site Contact Mail Error \n" . $e->getMessage());
}
}
示例13: ceospeaksAction
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('suggestions@winsandwants.com', 'winsandwants.com');
$mail->setReplyTo('suggestions@winsandwants.com', '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) . ".";
}
}
示例14: 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;
}
示例15: answerAction
public function answerAction()
{
$request = $this->getRequest();
$table = new ZfBlank_DbTable_Feedback();
if ($request->isPost()) {
$post = $request->getPost();
$msg = $table->find($post['id'])->getRow(0);
if ($msg->validateForm($post, new Admin_Form_Feedback())) {
$msg->setFromForm()->save();
if ($post['sendAnswer']) {
$mail = new Zend_Mail('UTF-8');
$mail->addTo($msg->getAuthor(), $msg->getContact());
$mail->setFrom($this->_adminAddress, $this->_adminBot);
$mail->setSubject('Answer on your message');
$mailText = "Message text (TODO)";
$mail->setBodyText($mailText);
//$mail->send();
}
$this->_redirect('/admin/feedback/index/type/unanswered');
}
$this->view->form = $msg->form();
} else {
$msg = $table->find($request->getParam('id'))->getRow(0);
$form = new Admin_Form_Feedback();
$form->setDefaults($msg->getValues());
$this->view->form = $form;
}
}