本文整理汇总了PHP中YiiMailMessage::addTo方法的典型用法代码示例。如果您正苦于以下问题:PHP YiiMailMessage::addTo方法的具体用法?PHP YiiMailMessage::addTo怎么用?PHP YiiMailMessage::addTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YiiMailMessage
的用法示例。
在下文中一共展示了YiiMailMessage::addTo方法的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: recover
/**
* Envia e-mail de recuperação de senha
*/
public function recover()
{
if (!$this->validate()) {
return false;
}
$usuario = Usuario::model()->ativos()->find("email = ?", array($this->email));
if ($usuario == null) {
$this->addError('email', Yii::t('RecuperarSenhaForm', 'Este e-mail está incorreto ou não está cadastrado.'));
return false;
}
$usuario->geraTokenRecuperacaoSenha();
$assunto = 'Recuperação de senha';
$view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.views.mail') . '/recuperarSenha.php', array('usuario' => $usuario), true);
$email = new YiiMailMessage();
$email->view = "template";
$email->setBody(array('content' => $view, 'title' => $assunto), 'text/html');
$email->subject = $assunto;
$email->addTo($this->email);
$email->from = Yii::app()->params['adminEmail'];
try {
Yii::app()->mail->send($email);
} catch (Exception $e) {
Yii::log('Erro ao enviar o e-mail: ' . $e->getMessage(), CLogger::LEVEL_ERROR);
return false;
}
return true;
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($id)
{
if (!empty($id) && !Yii::app()->user->isGuest) {
$customer_email = Yii::app()->user->name;
$customerModel = Customer::model()->findByAttributes(array('customer_email' => $customer_email));
$productId = $id;
$productModel = Product::model()->findByPk($productId);
$model = new Order();
$model->order_product_id = $productModel->product_id;
$model->order_customer_id = $customerModel->customer_id;
$model->order_amount = $productModel->product_price + $productModel->product_shipping_price;
if ($model->save()) {
$attribuits = Order::model()->findByPk($model->order_id);
$str = "Product Name:{$productModel->product_name}\r\n" . "Order Id:{$attribuits->order_id}\r\n" . "Order Product Id:{$attribuits->order_product_id}\r\n" . "Order Customer Id:{$attribuits->order_customer_id}\r\n" . "Total Amount With Shipping Charges:{$attribuits->order_amount}\r\n";
$message = new YiiMailMessage();
$message->subject = "Your order details";
$message->setBody($str);
$message->addTo(Yii::app()->user->name);
$message->from = $customerModel->customer_email;
Yii::app()->mail->send($message);
$this->redirect(array('view', 'id' => $model->order_id));
} else {
echo "booking failed";
}
}
}
示例4: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$message = new YiiMailMessage();
//this points to the file test.php inside the view path
$message->view = "login";
$params = array('name' => 'favormylikes@163.com');
$message->subject = 'My TestSubject';
$message->setBody($params, 'text/html');
$message->addTo('786112323@qq.com');
$message->from = 'favormylikes@163.com';
//Yii::app()->mail->send($message);
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$login_model = new LoginForm();
$sign_model = new User();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($login_model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST['LoginForm'])) {
$login_model->attributes = $_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if ($login_model->validate() && $login_model->login()) {
$this->redirect(Yii::app()->user->returnUrl);
}
}
// display the login form
$this->render('index', array('login_model' => $login_model, 'sign_model' => $sign_model));
}
示例5: 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();
}
示例6: actionEmail1
public function actionEmail1()
{
$message = new YiiMailMessage();
$message->setBody('Message content here with HTML', 'text/html');
$message->subject = 'My Subject';
$message->addTo('peterjkambey@yahoo.co.id');
$message->from = Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);
}
示例7: 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);
}
示例8: 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);
}
示例9: enviar
public function enviar()
{
$message = new YiiMailMessage();
$message->from = $this->email;
$message->addTo(Yii::app()->params['adminEmail']);
$message->subject = $this->subject;
$message->view = "template";
$view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.modules.pizzaria.views.mail') . '/contato.php', array('de' => $this->name, 'email' => $this->email, 'mensagem' => $this->message), true);
$message->setBody(array('content' => $view, 'title' => $this->subject), 'text/html');
return Yii::app()->mail->send($message) ? true : false;
}
示例10: SendMail
/**
* @author softdev
* @param string $subject
* @param string $email
* @param array $param
* @param string $view
*/
public function SendMail($subject = '', $email, $param, $link = '', $view)
{
$message = new YiiMailMessage();
//this points to the file test.php inside the view path
$message->view = trim($view);
$params = array('params' => $param, 'link' => $_SERVER['HTTP_ORIGIN'] . $link);
$message->subject = $subject;
$message->setBody($params, 'text/html');
$message->addTo(trim($email));
$message->from = Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);
}
示例11: SendMail
public function SendMail($data, $detail)
{
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->view = "price_submission";
$params = array('data' => $data, 'detail' => $detail);
$message->setBody($params, 'text/html');
$message->subject = "Price calculation submission";
$message->addTo($data->email);
$message->from = Yii::app()->params['adminEmail'];
if (Yii::app()->mail->send($message)) {
return "sukses";
}
}
示例12: sendMail
protected function sendMail($to, $subject, $body, $att = null)
{
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setBody($body);
$message->subject = $subject;
$message->addTo($to);
$message->from = Yii::app()->params['adminEmail'];
if ($att) {
$swiftAttachment = Swift_Attachment::fromPath($att);
$message->attach($swiftAttachment);
}
return Yii::app()->mail->send($message);
}
示例13: actionTeste
public function actionTeste()
{
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setBody('Message content here with HTML', 'text/html');
$message->subject = 'My Subject';
$message->addTo('yonatha@secom.pb.gov.br');
$message->from = Yii::app()->params['adminEmail'];
if (Yii::app()->mail->send($message)) {
echo 'E-mail enviado com sucesso';
} else {
echo 'Falha ao tentar enviar o e-mail';
}
}
示例14: 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);
}
示例15: enviarCorreo
public function enviarCorreo($idmiembro)
{
$miembro = Miembro::model()->findByPk($idmiembro);
Yii::log('miembro pwd ' . $miembro->password);
$body = "Sus datos de acceso al sistema de SOMIM son los siguientes:\n";
$body .= "Dirección de correo electrónico: " . $miembro->email;
$body .= "Contraseña: " . $miembro->password;
$message = new YiiMailMessage();
$message->subject = 'Acceso SOMIM';
$message->setBody($body, 'text/html');
$message->addTo($miembro->email);
$message->from = 'root@somim2.org';
Yii::app()->mail->send($message);
return true;
}