本文整理汇总了PHP中YiiMailMessage::setFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP YiiMailMessage::setFrom方法的具体用法?PHP YiiMailMessage::setFrom怎么用?PHP YiiMailMessage::setFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YiiMailMessage
的用法示例。
在下文中一共展示了YiiMailMessage::setFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mail
/**
* @static send a email
* @param array $data
* array('subject'=>?, 'params'=>array(), 'view'=>?, 'to'=>?, 'from'=>?)
* @param bool $requireView if true, it will only send email if view is existed
*/
public static function mail($data, $requireView = false)
{
// self::_setTestEmail($data, 'quocbao1087@gmail.com');
$message = new YiiMailMessage($data['subject']);
if (isset($data['view'])) {
if ($requireView) {
$path = YiiBase::getPathOfAlias(Yii::app()->mail->viewPath) . '/' . $data['view'] . '.php';
if (!file_exists($path)) {
return;
}
}
$message->view = $data['view'];
} elseif ($requireView) {
return;
}
$message->setBody($data['params'], 'text/html');
if (is_array($data['to'])) {
foreach ($data['to'] as $t) {
$message->addTo($t);
}
} else {
$message->addTo($data['to']);
}
$message->from = $data['from'];
$message->setFrom(array($data['from'] => Yii::app()->setting->getItem('title_all_mail')));
// test email using local mail server
if ($_SERVER['HTTP_HOST'] == 'localhost') {
Yii::app()->mail->transportType = 'smtp';
Yii::app()->mail->transportOptions = array('host' => 'localhost', 'username' => null, 'password' => null);
}
return Yii::app()->mail->send($message);
}
示例2: actionSendReminderEmails
/**
* Send reminder emails to those who haven't paid for their next week's box
*/
public function actionSendReminderEmails()
{
$Customers = Customer::model()->findAllWithNoOrders();
foreach ($Customers as $Cust) {
$validator = new CEmailValidator();
if ($validator->validateValue(trim($Cust->User->email))) {
$User = $Cust->User;
$User->auto_login_key = $User->generatePassword(50, 4);
$User->update_time = new CDbExpression('NOW()');
$User->update();
$adminEmail = SnapUtil::config('boxomatic/adminEmail');
$adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
$message = new YiiMailMessage('Running out of orders');
$message->view = 'customer_running_out_of_orders';
$message->setBody(array('Customer' => $Cust, 'User' => $User), 'text/html');
$message->addTo($Cust->User->email);
$message->addBcc($adminEmail);
//$message->addTo('francis.beresford@gmail.com');
$message->setFrom(array($adminEmail => $adminEmailFromName));
if (!@Yii::app()->mail->send($message)) {
echo '<p style="color:red"><strong>Email failed sending to: ' . $Cust->User->email . '</strong></p>';
} else {
echo '<p>Running out of orders message sent to: ' . $Cust->User->email . '</p>';
}
} else {
echo '<p style="color:red"><strong>Email not valid: "' . $Cust->User->email . '"</strong></p>';
}
}
echo '<p><strong>Finished.</strong></p>';
//Yii::app()->end();
}
示例3: send
/**
*
* 邮件发送方法
* @param string $email 邮件发送地址
* @param string $subject 邮件发送标题
* @param string $body 邮件发送内容
*/
public static function send($email, $subject, $body)
{
$message = new YiiMailMessage();
$message->setBody($body, 'text/html');
$message->subject = $subject;
$message->addTo($email);
$message->setFrom(array('admin@aladdin-holdings.com' => "萤火虫"));
return Yii::app()->mail->send($message);
}
示例4: SendMail
public function SendMail($email = "", $subject = '', $message = "")
{
$mail = new YiiMailMessage();
$mail->setBody($message, 'text/html');
$mail->subject = $subject;
$mail->addTo($email);
$mail->from = Yii::app()->params['regEmail'];
$mail->setFrom(array('reg@stolica-skidok.ru' => 'Столица Скидок'));
return Yii::app()->mail_reg->send($mail);
}
示例5: actionRubric
public function actionRubric($id = null)
{
if ($_POST['Form']) {
$model = new Form('new');
$this->performAjaxValidation($model);
$model->attributes = $_POST['Form'];
$model->date = time();
if ($_FILES['file']['tmp_name']) {
$file = CUploadedFile::getInstanceByName('file');
$model->file = $file->getName();
}
if ($model->save()) {
$text = 'Имя: ' . $model->name;
$text .= '<br />Фамилия: ' . $model->lastname;
$text .= '<br />E-mail: ' . $model->email;
$text .= '<br />Телефон: ' . $model->tel;
if ($model->arts) {
$text .= '<br />Артикулы под нанесение: ' . $model->arts;
}
if ($model->delivered) {
$text .= '<br />Желаемая дата заказа: ' . $model->delivered;
}
$text .= '<br />Кол-во цветов: ' . $model->color;
$text .= '<br />Тираж: ' . $model->tirazh;
$text .= '<br />Размеры: ' . $model->width . ' x ' . $model->height;
$text .= '<br />Драг.металы:';
$text .= '<br />Золото - ' . ($model->gold ? 'Да' : 'Нет');
$text .= '<br />Платина - ' . ($model->platina ? 'Да' : 'Нет');
if ($model->text) {
$text .= '<br />Примечание: ' . $model->text;
}
$message = new YiiMailMessage();
$message->setTo(array($this->getConfig('email3') => 'Комплекс Бар'));
$message->setFrom(array($model->email => $model->name . ' ' . $model->lastname));
$message->setSubject('Заказ на нанесение');
$message->setBody($text, 'text/html', 'utf8');
if ($_FILES['file']['tmp_name']) {
$fileNewPath = $_SERVER['DOCUMENT_ROOT'] . '/userdata/nanesenie/' . $file->getName();
$file->saveAs($fileNewPath);
$message->attach(Swift_Attachment::fromPath($fileNewPath));
}
Yii::app()->mail->send($message);
Yii::app()->user->setFlash('message', 'Спасибо за заказ. Наш менеджер свяжется с вами в ближайшее время.');
} else {
$this->render('rubric', $data);
}
$this->refresh();
}
$rubric = Rubrics::model()->findByPk($id);
$data = array('rubric' => $rubric);
$this->render('rubric', $data);
}
示例6: actionMailTes
public function actionMailTes()
{
$message = new YiiMailMessage();
$message->setBody('tes', 'text/html');
$message->setTo('neo_gazebo@yahoo.co.id');
$message->setSubject('tes');
$message->setFrom('admin@dcourier.com');
$html2pdf = Yii::app()->ePdf->HTML2PDF();
$html2pdf->WriteHTML('<p>hehehehe</p>');
$html2pdf->Output(dirname(Yii::app()->basePath) . '/pdf/tes.pdf', EYiiPdf::OUTPUT_TO_FILE);
$message->attach(Swift_Attachment::frompath(dirname(Yii::app()->basePath) . '/pdf/tes.pdf'));
Yii::app()->mail->send($message);
CVarDumper::dump(YiiMail::log($message), 10, true);
}
示例7: sendEmailOrderInfo
public static function sendEmailOrderInfo($params, $pdfFileNames)
{
$msg = new YiiMailMessage();
$msg->view = 'orderInfo';
$msg->setFrom(appParams('adminEmail'), appParams('adminEmailName'))->setTo($params['email'])->setSubject('Заказ номер ' . $params['orderBookingId'] . ' готов');
$msg->setBody($params, 'text/html');
foreach ($pdfFileNames as $key => $pdfInfo) {
$attachment = Swift_Attachment::fromPath($pdfInfo['filename']);
$attachment->setFilename($pdfInfo['visibleName']);
$msg->attach($attachment);
}
Yii::app()->mail->send($msg);
foreach ($pdfFileNames as $key => $pdfInfo) {
if (file_exists($pdfInfo['filename'])) {
unlink($pdfInfo['filename']);
}
}
}
示例8: recoverPassword
public function recoverPassword()
{
$u = User::model()->findByAttributes(array('username' => $this->username));
$newPassword = substr(md5(uniqid()), 0, 6);
$u->password = $newPassword;
$u->save();
$body = "Hello " . $u->first_name . ' ' . $u->last_name . ",\n\nYour login details are:\n\n";
$body .= "Username: " . $u->username . "\n";
$body .= "Password: " . $newPassword . "\n";
$body .= "\n\nPromocast Team";
$message = new YiiMailMessage();
$message->setTo(array($u->email => $u->first_name . ' ' . $u->last_name));
$message->setFrom(array('promocast1@gmail.com' => 'Promocast'));
$message->setSubject('Your password');
$message->setBody($body);
$numsent = Yii::app()->mail->send($message);
return true;
}
示例9: mail
/**
*
* Generic Mail sender method send the generic perfony html mail
* @param array $params
* contains any param passed on to the generic view file
*
* basePath : absolute server path
* imgPath : absolute path to images folder
* subject : ovious
* email : message mail will be send to
* sectionTitle : message Section tilte
* title : message title
* genericText : information text at the top
* view : defaults to 'contact' but could be different
* body : is the main body of the message
* link : appended to the message for direct access to the subject
* placeholders : key/value array to use to find/replace in body
*
* @param string $view : name of the view to be used a base
*/
public static function mail($params)
{
$k_path_url = (isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
$params['basePath'] = $k_path_url . $_SERVER['SERVER_NAME'] . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
$params['imgPath'] = $params['basePath'] . 'images/email';
$yiimail = new YiiMailMessage();
if (!isset($params['subject'])) {
$params['subject'] = Yii::t('mail', 'subject' . $params['key']);
}
$yiimail->setSubject($params['subject']);
$yiimail->setTo(array($params['email']));
$yiimail->setFrom(array(Yii::app()->params['adminEmail']));
if (!isset($params['sectionTitle'])) {
$params['sectionTitle'] = Yii::t('mail', 'sectionTitle' . $params['key']);
}
if (!isset($params['title'])) {
$params['title'] = Yii::t('mail', 'title' . $params['key']);
}
if (!isset($params['genericText'])) {
$params['genericText'] = Yii::t('mail', 'genericText' . $params['key']);
}
$yiimail->view = isset($params['view']) ? $params['view'] : 'contact';
if (!isset($params['body'])) {
$params['body'] = Yii::t('mail', 'body' . $params['key']);
}
if (isset($params['link'])) {
$params['body'] .= "<br/><a href='" . Yii::app()->createAbsoluteUrl("/" . $params['link']) . "'>" . Yii::t(PTranslate::CAT_MAILS, 'Direct Link to access') . "</a>";
}
if (isset($params['placeholders'])) {
foreach ($params['placeholders'] as $key => $val) {
//throw new CHttpException('pouet avant : '.$params['placeholders'].' après : '.str_replace($key, $val, $params['placeholders']));
$params['body'] = str_replace($key, $val, $params['body']);
}
}
$yiimail->setBody($params, 'text/html');
if (Yii::app()->params['sendMails']) {
Yii::app()->mail->send($yiimail);
}
}
示例10: sendMail
public static function sendMail($data)
{
// self::_setTestEmail($data, 'quocbao1087@gmail.com');
$message = new YiiMailMessage($data['subject']);
$message->setBody($data['message'], 'text/html');
if (is_array($data['to'])) {
foreach ($data['to'] as $t) {
$message->addTo($t);
}
} else {
$message->addTo($data['to']);
}
if (isset($data['cc'])) {
$message->setCc($data['cc']);
}
$message->from = $data['from'];
$message->setFrom(array($data['from'] => Yii::app()->setting->getItem('title_all_mail')));
// test email using local mail server
if ($_SERVER['HTTP_HOST'] == 'localhost') {
Yii::app()->mail->transportType = 'smtp';
Yii::app()->mail->transportOptions = array('host' => 'localhost', 'username' => null, 'password' => null);
}
return Yii::app()->mail->send($message);
}
示例11: quickMail
/**
* Send email to an address
*
* @param string $email receiver's address
* @param string $view path to view used by mailer (Yii's alias format)
* @param array $data associative array passed to view
*/
function quickMail($email, $view, $data, $subject = 'Flexicore Member Registration Confirmation')
{
Yii::import('Core.extensions.vendors.mail.YiiMailMessage');
$viewName = end(explode('.', $view));
Yii::app()->mail->viewPath = str_replace('.' . $viewName, '', $view);
//send mail
$message = new YiiMailMessage();
$message->view = $viewName;
$message->setSubject($subject);
$message->setBody($data, 'text/html');
$message->addTo($email);
if (hasParam('Settings::ADMIN_EMAIL')) {
$message->setFrom(array(Settings::ADMIN_EMAIL => Settings::SITE_NAME));
}
try {
Yii::app()->mail->send($message);
} catch (Exception $ex) {
FErrorHandler::logError($ex->getMessage());
}
}
示例12: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
// main contact form
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
$subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
$headers = "From: {$name} <{$model->email}>\r\n" . "Reply-To: {$model->email}\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8";
mail('LinxCircle Contact <contact@linxcircle.com>', $subject, $model->body, $headers);
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
} else {
if (isset($_POST['ContactableForm'])) {
// jquery widget
// Assign contact info
$name = stripcslashes($_POST['name']);
$emailAddr = stripcslashes($_POST['email']);
$issue = stripcslashes($_POST['issue']);
$comment = stripcslashes($_POST['message']);
$subject = stripcslashes($_POST['subject']);
//$name='=?UTF-8?B?'.base64_encode($name).'?=';
$subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
// Format message
$contactMessage = "<div>\n\t\t\t<p><strong>Name:</strong> {$name} <br />\n\t\t\t<strong>E-mail:</strong> {$emailAddr} <br />\n\t\t\t<strong>Issue:</strong> {$issue} </p>\n\t\t\t\t\n\t\t\t<p><strong>Message:</strong> {$comment} </p>\n\t\t\t\t\n\t\t\t<p><strong>Sending IP:</strong> {$_SERVER['REMOTE_ADDR']}<br />\n\t\t\t<strong>Sent via:</strong> {$_SERVER['HTTP_HOST']}</p>\n\t\t\t</div>";
// Send and check the message status
$message = new YiiMailMessage();
$message->setBody($contactMessage, 'text/html');
$message->setSubject($subject);
$message->setTo(array('contact@linxcircle.com' => 'LinxCircle Contact'));
$message->setFrom(array($emailAddr => $name . " (LinxCircle)"));
$message->setReplyTo(array($emailAddr => $name . " (LinxCircle)"));
$result = Yii::app()->mail->send($message);
$response = $result ? "success" : "failure";
$output = json_encode(array("response" => $response, "result" => $result));
header('content-type: application/json; charset=utf-8');
echo $output;
return;
}
}
$this->render('contact', array('model' => $model));
}
示例13: sendEmail
public function sendEmail($emails, $subject, $message)
{
if ($this->getHost() == null) {
return;
}
/**
* @var $mailer YiiMail
*/
$mailer = Yii::createComponent(array('class' => 'YiiMail', 'transportType' => $this->getMailMethod(), 'transportOptions' => array('host' => $this->getHost()), 'logging' => false));
$mailerTransport = $mailer->getTransport();
if ($this->getAuthUser() !== null) {
//нужна авторизация на сервере
$mailerTransport->setUsername(trim($this->getAuthUser()))->setPassword(trim($this->getAuthPassword()));
} else {
$mailerTransport->setUsername(null)->setPassword(null);
}
$mailMessage = new YiiMailMessage();
$mailMessage->setBody($message, 'text/plain', 'utf-8');
$mailMessage->setFrom($this->getSentFrom());
$mailMessage->setSubject($subject);
$mailMessage->setTo($emails);
$errorMessage = false;
try {
if (!$mailer->send($mailMessage, $failures)) {
$errorMessage = sprintf("Ошибка при отправке почты:\n %s", print_r($failures, true));
}
} catch (Exception $e) {
$errorMessage = $e->getMessage();
}
if ($errorMessage) {
$this->log($errorMessage);
}
}
示例14: save
public function save($runValidation = true, $attributes = null)
{
// check if account_email is associated with any account at all
$account = Account::model()->getAccountByEmail($this->account_email);
if ($account == null) {
$this->addError('account_email', 'This email is not associated with any account.');
return false;
}
// create record
if ($this->isNewRecord) {
$this->account_id = $account->account_id;
$this->account_password_reset_rand_key = $this->generateRandomKey($account->account_created_date);
$this->account_password_reset_rand_key_expiry = $this->getExpiryDate();
}
$result = parent::save($runValidation, $attributes);
if ($result) {
// email customer step to reset password
$message = new YiiMailMessage();
$message->view = "passwordResetEmail";
//userModel is passed to the view
$message->setBody(array('reset_url' => $this->generateResetURL()), 'text/html');
$message->setSubject("[" . Yii::app()->name . "] Password Reset");
$message->addTo($this->account_email);
$message->setFrom(array(Yii::app()->params['adminEmail'] => 'Admin (LinxCircle)'));
Yii::app()->mail->send($message);
}
return $result;
}
示例15: actionRegister
/**
* Displays the register page
*/
public function actionRegister()
{
$model = new User();
$vars = array();
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->scenario = 'register';
if ($model->save()) {
$Customer = new Customer();
$Customer->attributes = $_POST['Customer'];
$Customer->save();
if (!$Customer->Location->is_pickup) {
$CustLoc = new UserLocation();
$CustLoc->user_id = $Customer->user_id;
$CustLoc->location_id = $Customer->location_id;
$CustLoc->address = $model->user_address;
$CustLoc->address2 = $model->user_address2;
$CustLoc->suburb = $model->user_suburb;
$CustLoc->state = $model->user_state;
$CustLoc->postcode = $model->user_postcode;
$CustLoc->phone = !empty($model->user_phone) ? $model->user_phone : $model->user_mobile;
$CustLoc->save(false);
}
$model->user_id = $Customer->user_id;
$model->update(array('user_id'));
$Auth = Yii::app()->authManager;
$Auth->assign('customer', $model->id);
//Send email
$adminEmail = SnapUtil::config('boxomatic/adminEmail');
$adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
$message = new YiiMailMessage('Welcome to ' . Yii::app()->name);
$message->view = 'welcome';
$message->setBody(array('User' => $model, 'newPassword' => $_POST['User']['password']), 'text/html');
$message->addTo($adminEmail);
$message->addTo($model->email);
$message->setFrom(array($adminEmail => $adminEmailFromName));
if (!@Yii::app()->mail->send($message)) {
$mailError = true;
}
$identity = new UserIdentity($model->email, $_POST['User']['password']);
$identity->authenticate();
Yii::app()->user->login($identity);
User::model()->updateByPk($identity->id, array('last_login_time' => new CDbExpression('NOW()')));
$this->redirect(array('customer/welcome'));
}
}
$model->password = '';
$model->password_repeat = '';
$vars['model'] = $model;
// $this->render('register',array('model'=>$model));
$this->render('register', $vars);
}