本文整理汇总了PHP中Nette\Mail\Message::setHTMLBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setHTMLBody方法的具体用法?PHP Message::setHTMLBody怎么用?PHP Message::setHTMLBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Mail\Message
的用法示例。
在下文中一共展示了Message::setHTMLBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Message
} else {
$mail = new Message();
$mail->setFrom("C-SCAN'16 <{$mailer_username}>")->addTo($_POST['email'])->setSubject("C-SCAN'16 Registration");
$mailer = new Nette\Mail\SmtpMailer(array('host' => 'smtp.gmail.com', 'username' => $mailer_username, 'password' => $mailer_password, 'secure' => 'ssl'));
$factory = new ValidatorFactory(new Translator('en'));
$messages = array('required' => 'The :attribute field is required.', 'max' => 'Please enter a valid :attribute number.', 'min' => 'Please enter a valid :attribute field.', 'email' => 'Please enter a valid email address.', 'numberic' => 'The :attribute field should consist only of digits.', 'integer' => 'The :attribute field should be selected.', 'digits_between' => 'The :attribute field should be contain minimum of 10 digits.');
if ($_POST['type'] == "student") {
$rules = array('college' => 'required|integer', 'faculty' => 'required', 'name' => 'required', 'email' => 'required|email', 'phone' => 'required|numeric|digits_between:10,15', 'course' => 'required', 'semester' => 'required', 'gender' => 'required', 'food' => 'required');
$validator = $factory->make($_POST, $rules, $messages);
if ($validator->passes()) {
$num = Student::where('college', $_POST['college'])->count();
$_POST['regid'] = $num + 1;
if ($v = Student::create($_POST)) {
$regid = $v->colg->abbr . "S" . str_pad($_POST['regid'], 3, '0', STR_PAD_LEFT);
$name = $_POST['name'];
$mail->setHTMLBody("Hi {$name},<br/>You have successfully registered for C-SCAN 2016. Your registration ID is " . $regid . ". The confirmation regarding the same will be done via email on or before 1st February.<br/>For more details and updates, please visit our <a href='http://www.cscan.org.in'>website</a>.<br/><br/>Thank you.<br/><br/>Yours Sincerely,<br/>Organising Team,<br/>C-SCAN 2016.");
$mailer->send($mail);
} else {
$error = ERROR_DB;
}
} else {
$error = ERROR_INVALID;
}
} else {
if ($_POST['type'] == "faculty") {
$rules = array('college' => 'required|integer', 'name' => 'required', 'email' => 'required|email', 'phone' => 'required|numeric|digits_between:10,15', 'designation' => 'required', 'interest' => 'required', 'gender' => 'required', 'food' => 'required');
$validator = $factory->make($_POST, $rules, $messages);
if ($validator->passes()) {
$num = Faculty::where('college', $_POST['college'])->count();
$_POST['regid'] = $num + 1;
if ($v = Faculty::create($_POST)) {
示例2: sendEmail
/**
* Here's the magic
*
* @param array $recipients
* @param null $subject
* @param array $data
* @throws EmailException
*/
private function sendEmail($recipients = array(), $subject = '', $data)
{
// recipients check
if (!is_array($recipients)) {
$recipients = array($recipients);
}
if (count($recipients) < 1) {
throw new EmailException('No subscribers provided. (possibly none in your system)');
}
// try sending e-mail
try {
$mail = new \Nette\Mail\Message();
$mail->setFrom($this->senderEmail, $this->senderName)->setSubject($subject);
foreach ($recipients as $recipient) {
$mail->addBcc($recipient);
}
// set HTML / or plaintext body
if ($this->htmlEmail == TRUE) {
$mail->setHTMLBody($this->getEmailTemplate($data));
} else {
$mail->setBody($this->getEmailTemplate($data));
}
$this->mailer->send($mail);
} catch (\Exception $e) {
throw new EmailException($e->getMessage());
}
}