本文整理匯總了PHP中YiiMailMessage::setReplyTo方法的典型用法代碼示例。如果您正苦於以下問題:PHP YiiMailMessage::setReplyTo方法的具體用法?PHP YiiMailMessage::setReplyTo怎麽用?PHP YiiMailMessage::setReplyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類YiiMailMessage
的用法示例。
在下文中一共展示了YiiMailMessage::setReplyTo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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));
}
示例2: SendMail
public function SendMail($mail = array())
{
$mailer = new YiiMail();
$mailer->transportType = 'smtp';
$mailer->transportOptions = array('host' => Config::model()->getValueByKey('host_sendmail'), 'username' => Config::model()->getValueByKey('username_sendmail'), 'password' => Config::model()->getValueByKey('password_sendmail'), 'port' => Config::model()->getValueByKey('port_sendmail'), 'encryption' => Config::model()->getValueByKey('encryption_sendmail'));
$message = new YiiMailMessage();
$message->setFrom(array(Config::model()->getValueByKey('username_sendmail') => Config::model()->getValueByKey('displayname_sendmail')));
$message->setTo(array($mail['mailto']));
$message->setReplyTo(array($mail['replyto']));
$message->setSubject($mail['subject']);
$message->setBody($mail['body'], 'text/html');
$mailer->send($message);
}