本文整理汇总了PHP中Mailer类的典型用法代码示例。如果您正苦于以下问题:PHP Mailer类的具体用法?PHP Mailer怎么用?PHP Mailer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mailer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeRegistrationSubmit
public function executeRegistrationSubmit(sfWebRequest $request)
{
$this->forwardErrorIf($this->getUser()->isAuthenticated(), "User can not register if already logged in.");
$this->forward404Unless($request->isMethod('post'));
$this->form = new RegistrationForm();
$this->form->bind($request->getParameter('register'));
if ($this->form->isValid()) {
$account = $this->form->save();
$profile = new Profile();
$profile->uid = $account->id;
$profile->username = $account->username;
$profile->first_name = $request->getPostParameter('register[first_name]');
$profile->middle_name = $request->getPostParameter('register[middle_name]');
$profile->last_name = $request->getPostParameter('register[last_name]');
$profile->name = $profile->first_name . " " . $profile->middle_name . " " . $profile->last_name;
$profile->pic = "0.jpg";
$profile->save();
$mailer = new Mailer();
if ($mailer->send($account->email, sfConfig::get('app_registration_email_from_address'), sfConfig::get('app_site_name'), sfConfig::get('app_registration_email_subject'), " \nDear " . $profile->first_name . ",\n\n\nWelcome to " . sfConfig::get('app_site_name') . ". We are very pleased you decided to start the\nnext generation of your online social life with us! Below you will\nfind an activation link. Please click this link to verify your\naccount before logging in. If you have any trouble, please contact\nus via the \"Contact\" link on the home page of our web site.\n\n\nVERIFICATION LINK (Please click or paste into your browser address bar)\n-----------------------------------------------------------------------\n" . "http://rks.ath.cx:8080" . $this->generateUrl('verify') . '/id/' . $account->id . '/vid/' . md5($account->created_at) . "\n-----------------------------------------------------------------------\n\nIf you feel you were added to our system by mistake, please contact\nus via the \"Contact\" link on the home page of our web site.\n\n--The " . sfConfig::get('app_site_name') . " Support Team\n ")) {
$this->getUser()->setFlash('info', "Registration was successful, please check your email to verify your account");
$this->redirect('account/login');
} else {
$this->getUser()->setFlash('error', "Error occured sending with our mail server, please register again using a different username");
$this->redirect('account/register');
}
}
$this->setTemplate('register');
}
示例2: actionPerform
function actionPerform(&$skin, $moduleID)
{
$recordSet = $skin->main->databaseConnection->Execute("SELECT user_groups.* , COUNT(users.name) AS user_count \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$skin->main->databaseTablePrefix}user_groups AS user_groups LEFT OUTER JOIN\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$skin->main->databaseTablePrefix}users AS users\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_groups.user_group_id = users.user_group_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_groups.user_group_id>1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_groups.user_group_id");
//Check for error, if an error occured then report that error
if (!$recordSet) {
trigger_error("Unable to get user list\nreason is : " . $skin->main->databaseConnection->ErrorMsg());
} else {
$rows = $recordSet->GetRows();
$skin->main->controlVariables["sendMessage"]['groupList'] = $rows;
$skin->main->controlVariables["sendMessage"]['moduleId'] = $this->getModuleID($skin->main);
}
$skin->main->controlVariables["sendMessage"]['errorInfo'] = "";
$skin->main->controlVariables["sendMessage"]['succeed'] = false;
if (isset($_POST["event"]) && $_POST["event"] == 'sendMessage') {
$mailer = new Mailer($skin->main);
for ($i = 0; $i < sizeof($_POST["groups"]); $i++) {
$recordSet = $skin->main->databaseConnection->Execute("SELECT username FROM {$skin->main->databaseTablePrefix}users AS users WHERE user_group_id=" . $_POST['groups'][$i]);
if (!$recordSet) {
trigger_error("Unable to get group members\nreason is : " . $skin->main->databaseConnection->ErrorMsg());
return "";
} else {
$rows = $recordSet->GetRows();
for ($j = 0; $j < sizeof($rows); $j++) {
$mailer->addUserAddress($rows[$j]["username"]);
}
}
}
$mailer->Subject = $_POST["subject"];
$mailer->Body = $_POST["content"];
$mailer->Send();
$skin->main->controlVariables["sendMessage"]['errorInfo'] = $mailer->ErrorInfo;
$skin->main->controlVariables["sendMessage"]['succeed'] = $mailer->ErrorInfo == "";
}
}
示例3: handle
/**
* Execute the job.
*
* @return void
*/
public function handle(Mailer $mailer)
{
//
$mailer->send('emails.welcome', ['user' => $this->user], function ($m) {
//
});
}
示例4: handle
/**
* Execute the job.
*
* @return void
*/
public function handle(Mailer $mailer)
{
$mailer->send('mail.welcome', ['data' => 'data'], function ($message) {
$message->from('nwambachristian@gmail.com', 'Christian Nwmaba');
$message->to('nwambachristian@gmail.com');
});
}
示例5: fn_init_mailer
/**
* Init mail engine
*
* @return boolean always true
*/
function fn_init_mailer()
{
if (defined('MAILER_STARTED')) {
return true;
}
$mailer_settings = fn_get_settings('Emails');
if (!(include DIR_CORE . 'class.mailer.php')) {
fn_error(debug_backtrace(), "Can't find Mail class", false);
}
$mailer = new Mailer();
$mailer->LE = defined('IS_WINDOWS') ? "\r\n" : "\n";
$mailer->PluginDir = DIR_LIB . 'phpmailer/';
if ($mailer_settings['mailer_send_method'] == 'smtp') {
$mailer->IsSMTP();
$mailer->SMTPAuth = $mailer_settings['mailer_smtp_auth'] == 'Y' ? true : false;
$mailer->Host = $mailer_settings['mailer_smtp_host'];
$mailer->Username = $mailer_settings['mailer_smtp_username'];
$mailer->Password = $mailer_settings['mailer_smtp_password'];
} elseif ($mailer_settings['mailer_send_method'] == 'sendmail') {
$mailer->IsSendmail();
$mailer->Sendmail = $mailer_settings['mailer_sendmail_path'];
} else {
$mailer->IsMail();
}
Registry::set('mailer', $mailer);
define('MAILER_STARTED', true);
return true;
}
示例6: lostpass
public function lostpass()
{
if ($this->f3->exists('POST.lostpass')) {
$audit = \Audit::instance();
$this->f3->scrub($_POST);
$this->f3->set('SESSION.flash', array());
$members = new Members($this->db);
// validate form
if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
}
if ($members->count(array('email=?', $this->f3->get('POST.email'))) == 0) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Couldn\'t find an account associated with that email address.'));
}
if (count($this->f3->get('SESSION.flash')) === 0) {
// generate random password
$this->f3->set('password', md5(time()));
$this->f3->set('POST.password', password_hash($this->f3->get('password'), PASSWORD_DEFAULT));
$mailer = new Mailer();
$message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': Password Reset')->setFrom(array($this->f3->get('noreplyemail') => $this->f3->get('tcgname')))->setTo(array($this->f3->get('POST.email')))->setReplyTo(array($this->f3->get('tcgemail')))->setBody(Template::instance()->render('app/templates/emails/pwreset.htm'), 'text/html');
// save new password and email to member
if ($members->edit($members->read(array('email=?', $this->f3->get('POST.email')), [])[0]->id, array('password')) && $mailer->send($message)) {
$this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your password has been reset! Please check your email.'));
} else {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'Password reset failed. Please try again or contact us for assistance.'));
}
}
}
$this->f3->set('content', 'app/views/lostpass.htm');
echo Template::instance()->render('app/templates/default.htm');
}
示例7: sandmailAction
function sandmailAction()
{
$firstnameErrText = "";
$lastnameErrText = "";
$addressErrText = "";
$exemplarsErrText = "";
if (empty($_POST['firstname'])) {
$firstnameErrText = "не ввели имя!";
}
if (empty($_POST['lastname'])) {
$lastnameErrText = "<span class=err> не ввели фамилию! </span> ";
}
if (empty($_POST['address'])) {
$addressErrText = "<span class=err> не ввели адрес! </span> ";
}
if (empty($_POST['exemplars'])) {
$exemplarsErrText = "<span class=err> не выбрано количество! </span> ";
}
if (!empty($_POST['firstname']) && !empty($_POST['lastname']) && !empty($_POST['address']) && !empty($_POST['exemplars'])) {
$body = $row['FIO'] . "\r\n" . $row['BookName'] . ", количество: " . $_POST["exemplars"] . "\r\n" . $_POST["firstname"] . " " . $_POST["lastname"] . " " . $_POST["address"];
$title = substr(htmlspecialchars(trim($_POST['lastname'])), 0, 1000) . " ";
$title .= substr(htmlspecialchars(trim($_POST['firstname'])), 0, 1000) . ", ";
$title .= "Адресс :" . substr(htmlspecialchars(trim($_POST['address'])), 0, 1000);
$to = 'admin@test.ru';
$sendaddress = mail($to, $title, 'Заказ:' . $body);
$mailer = new Mailer();
try {
$mailer->send($to, $title, 'Заказ:' . $body);
} catch (Exception $err) {
$sendaddressErr = true;
}
}
include_once 'views/sendmail.tpl';
}
示例8: indexAction
/**
* Handles requested "/" route
*/
public function indexAction()
{
// handle contact form
if (!empty($_POST['form_submit'])) {
$formValidator = new FormValidator($_POST['form'], $this->view);
// if there were no errors
if ($formValidator->isValid()) {
// format user submitted data
$data = array();
$data[] = '<table>';
foreach ($_POST['form'] as $field => $value) {
$data[] = '<tr><th>' . ucwords(str_replace(array('-', '_'), ' ', $field)) . '</th><td>' . nl2br($value) . '</td></tr>';
}
$data[] = '</table>';
// send message
$mailer = new Mailer();
$result = $mailer->sendSystemMessage(implode("\n", $data), $_POST['form_submit']);
if ($result) {
$this->router->redirect('/thanks');
die;
}
} else {
$this->errorMessages = $formValidator->getFormattedErrors();
}
}
}
示例9: actionPerform
function actionPerform(&$skin, $moduleID)
{
$recordSet = $skin->main->databaseConnection->Execute("SELECT * FROM {$skin->main->databaseTablePrefix}users");
//Check for error, if an error occured then report that error
if (!$recordSet) {
trigger_error("Unable to get user list\nreason is : " . $skin->main->databaseConnection->ErrorMsg());
} else {
$rows = $recordSet->GetRows();
$skin->main->controlVariables["sendMessage"]['userList'] = $rows;
$skin->main->controlVariables["sendMessage"]['moduleId'] = $this->getModuleID($skin->main);
}
$skin->main->controlVariables["sendMessage"]['errorInfo'] = "";
$skin->main->controlVariables["sendMessage"]['succeed'] = false;
if (isset($_POST["event"]) && $_POST["event"] == 'sendMessage') {
$mailer = new Mailer($skin->main);
for ($i = 0; $i < sizeof($_POST["users"]); $i++) {
$mailer->addUserAddress($_POST["users"][$i]);
}
$mailer->Subject = $_POST["subject"];
$mailer->Body = $_POST["content"];
$mailer->Send();
$skin->main->controlVariables["sendMessage"]['errorInfo'] = $mailer->ErrorInfo;
$skin->main->controlVariables["sendMessage"]['succeed'] = $mailer->ErrorInfo == "";
}
}
示例10: process
private function process()
{
$this->f3->scrub($_POST);
$audit = \Audit::instance();
$this->f3->set('SESSION.flash', array());
// validate form
if (!preg_match("/^[\\w\\- ]{2,30}\$/", $this->f3->get('POST.name'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name.'));
}
if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
}
if (!empty($this->f3->get('POST.url')) && !$audit->url($this->f3->get('POST.url'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid URL.'));
}
if (empty($this->f3->get('POST.message'))) {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please include a message!'));
}
// honey pot
if ($this->f3->get('POST.username') !== '') {
$this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please do not use autofill or similar tools!'));
}
// if there are no errors, process the form
if (count($this->f3->get('SESSION.flash')) === 0) {
$this->f3->set('POST.level', $this->f3->get('member')->level + 1);
$mailer = new Mailer();
$message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': Contact Form')->setFrom(array($this->f3->get('noreplyemail') => 'MyTCG'))->setTo(array($this->f3->get('tcgemail')))->setReplyTo(array($this->f3->get('POST.email')))->setBody(Template::instance()->render('app/templates/emails/contact.htm'), 'text/html');
if ($mailer->send($message)) {
$this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your form has been sent. Thanks for contacting us!'));
} else {
$this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
}
}
}
示例11: actionIndex
/**
* Invitation form and processing of invited user details
*/
public function actionIndex($p)
{
if ($this->request->isPost()) {
$firstName = Fari_Decode::accents($this->request->getPost('first'));
$lastName = Fari_Decode::accents($this->request->getPost('last'));
$email = $this->request->getPost('email');
if (!Fari_Filter::isEmail($email) or empty($firstName)) {
$this->bag->message = array('status' => 'fail', 'message' => 'Whoops, make sure you enter a full name and proper email address.');
$this->bag->first = $this->request->getRawPost('first');
$this->bag->last = $this->request->getRawPost('last');
$this->bag->email = $this->request->getRawPost('email');
} else {
$name = $this->accounts->newInvitation($firstName, $lastName, $email);
// mail the instructions
$mail = new Mailer();
try {
$mail->sendInvitation();
} catch (UserNotFoundException $e) {
$this->redirectTo('/error404/');
}
$this->flashSuccess = "{$name} is now added to your account. An email with instructions was sent to {$email}";
$this->redirectTo('/users/');
}
}
$this->bag->tabs = $this->user->inRooms();
$this->renderAction('new');
}
示例12: createProfile
/**
* Felhasználói profil létrehozása.
*/
private function createProfile()
{
if (isset($_POST['signUpSubmit'])) {
include_once FRAME_PATH . 'Mailer.php';
$mailer = new Mailer();
$name = $this->db->real_escape_string($_POST['signUpName']);
$email = $this->db->real_escape_string($_POST['signUpEmail']);
$pass = $this->db->real_escape_string($_POST['signUpPassword']);
$passCheck = $this->db->real_escape_string($_POST['signUpPasswordCheck']);
if (empty($name)) {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E1 . '</div></div>';
} else {
if (empty($email)) {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E2 . '</div></div>';
} else {
if (!preg_match("/([\\w\\-]+\\@[\\w\\-]+\\.[\\w\\-]+)/", $email)) {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E4 . '</div></div>';
} else {
if (empty($pass)) {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E5 . '</div></div>';
} else {
if (strlen($pass) < 8) {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E6 . '</div></div>';
} else {
if ($pass != $passCheck) {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E7 . '</div></div>';
} else {
$checkEmail = $this->db->query("SELECT email FROM users WHERE email = '" . $email . "'") or $this->dbLog($this->db, self::ME, __LINE__);
if ($checkEmail->num_rows < 1) {
$pass_hash = $this->passwordHash($pass);
$userId = $this->createId($this->db, 12, "users", "userId");
$url_token = $this->createId($this->db, 20, "users", "token");
$sql = "INSERT INTO users (userID, userName, email, password, rights, token) VALUES ('" . $userId . "', '" . $name . "', '" . $email . "', '" . $pass_hash . "', 'pending', '" . $url_token . "')";
$this->db->query($sql) or $this->dbLog($this->db, self::ME, __LINE__);
$mailer->sendAutoMail($email, SIGNUP_MAIL_SUBJECT, SIGNUP_MAIL_BODY . '<a href="http://majtenyim.matyasvendeglo.hu/index.php?m=settings&a=confirmProfile&token=' . $url_token . '">' . SIGNUP_CONFIRM_BTN . '</a>');
$objectId = $this->createId($this->db, 20, 'objects', 'objectId');
$token = $this->createId($this->db, 24, 'objects', 'token');
$sql = "INSERT INTO objects (objectId,token) VALUES ('" . $objectId . "','" . $token . "')";
$this->db->query($sql) or $this->dbLog($this->db, self::ME, __LINE__);
mkdir('sky/' . $token);
$sql = "INSERT INTO metadata (objectId,objectName,objectType,objectSize,owner,lastModifiedByOnline) VALUES ('" . $objectId . "','" . $token . "','folder','0','" . $userId . "','" . date('Y-m-d H:i:s') . "')";
$this->db->query($sql) or $this->dbLog($this->db, self::ME, __LINE__);
$sql = "UPDATE users SET cloudObject = '" . $objectId . "' WHERE userId = '" . $userId . "'";
$this->db->query($sql) or $this->dbLog($this->db, self::ME, __LINE__);
echo '<div class="absErrorHolder"><div class="succeed">' . SIGNUP_SUCCESS . '</div></div>';
} else {
echo '<div class="absErrorHolder"><div class="error">' . SIGNUP_E3 . '</div></div>';
}
}
}
}
}
}
}
}
}
示例13: hook_shipment_post
function hook_shipment_post(&$user, &$shipment, &$session)
{
$mailer = new Mailer($user['folder']);
$mailer->addRcpt($shipment->ship_contact, 'pickup@minimaxexpress.com');
$mailer->dataObj = $shipment->toArray();
$mailer->dataObj['del_note'] = $session->account_notes . " " . $mailer->dataObj['del_note'];
$mailer->template = "order_summary";
$mailer->subject = "WEB ORDER #" . $shipment->ext_id;
$mailer->send();
}
示例14: send
public function send($parsed_object, $parcel, $debug = FALSE)
{
$parsed_object->settings = $parcel->settings;
$mailer = new Mailer($parsed_object);
$response = $mailer->send();
if (!$response) {
$this->show_error('An unknown error has occurred when sending email with your server.');
}
return new Postmaster_Service_Response(array('status' => $response ? POSTMASTER_SUCCESS : POSTMASTER_FAILED, 'parcel_id' => $parcel->id, 'channel_id' => isset($parcel->channel_id) ? $parcel->channel_id : FALSE, 'author_id' => isset($parcel->entry->author_id) ? $parcel->entry->author_id : FALSE, 'entry_id' => isset($parcel->entry->entry_id) ? $parcel->entry->entry_id : FALSE, 'gmt_date' => $this->now, 'service' => $parcel->service, 'to_name' => $parsed_object->to_name, 'to_email' => $parsed_object->to_email, 'from_name' => $parsed_object->from_name, 'from_email' => $parsed_object->from_email, 'cc' => $parsed_object->cc, 'bcc' => $parsed_object->bcc, 'subject' => $parsed_object->subject, 'message' => !empty($parsed_object->message) ? $parsed_object->message : $parsed_object->html_message, 'html_message' => $parsed_object->html_message, 'plain_message' => $parsed_object->plain_message, 'parcel' => $parcel));
}
示例15: sendHTML
/**
* Send an email as both HTML and plaintext
*
* @return bool
*/
public function sendHTML($to, $from, $subject, $htmlContent, $attachedFiles = false, $customheaders = false, $plainContent = false)
{
$result = $this->sendPostmarkEmail($to, $from, $subject, $htmlContent, $attachedFiles, $customheaders, $plainContent);
if ($result === false) {
// Fall back to regular Mailer
$fallbackMailer = new Mailer();
$result = $fallbackMailer->sendHTML($to, $from, $subject, $htmlContent, $attachedFiles, $customheaders, $plainContent);
}
return $result;
}