本文整理汇总了PHP中Mail类的典型用法代码示例。如果您正苦于以下问题:PHP Mail类的具体用法?PHP Mail怎么用?PHP Mail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lauchScript1
function lauchScript1()
{
$managers = new Managers('pdo', PDOFactory::getMysqlConnexion());
$reservationManager = $managers->getManagerOf('announcementreservations');
$announcementManager = $managers->getManagerOf('announcements');
$userManager = $managers->getManagerOf('users');
//On supprime les réservations non-payée
$reservationManager->deletePassedWaitingPaiement();
$listOfReservationPassed = $reservationManager->getListOfPassed();
$messageMail = new Mail();
$countRervation = 0;
foreach ($listOfReservationPassed as $reservation) {
$reservation->setStateId(PaiementStates::CANCELED);
$reservation->setUpdatedTime(time());
$reservation->setKeyCheck(null);
$reservationManager->save($reservation);
$announce = $announcementManager->get($reservation->getAnnouncementId());
$userOwner = $userManager->get($reservation->getUserOwnerId());
$userSubscriber = $userManager->get($reservation->getUserSubscriberId());
$messageMail->sendReservationSubscriberCanceled($userOwner, $userSubscriber, $announce);
$messageMail->sendAdminReservationSubscriberCanceled($userOwner, $userSubscriber, $announce, $reservation);
$countRervation++;
}
if ($countRervation > 0) {
echo $countRervation . ' mail(s) d\'annulation de réservation envoyé(s) !';
}
}
示例2: enviar_newsletter
/**
* Método que envia os e-mails para os professores semanalmente
*/
public function enviar_newsletter()
{
set_time_limit(600);
if (!$this->configs->status) {
//impedindo o envio antes da ativação
die('O envio esta desativado');
}
if ($this->configs->diaEnvio != (int) date('N')) {
//Impedindo o envio fora do dia correto
die('Hoje não é dia de envio');
}
$professorObj = new Kernel_Models_Contratos();
$constaEnvio = new Kernel_Models_NewsletterContas();
$usuarioSistema = new Kernel_Models_Usuario();
$todos = $professorObj->aceitaReceber(1, $this->configs->destinatariosEspecificos);
$mail = new Mail();
while ($professor = $todos->fetchObject()) {
$emailDestino = $professor->email;
if ($this->configs->efetuarTeste) {
$emailDestino = $this->configs->emailTeste;
}
if (filter_var($emailDestino, FILTER_VALIDATE_EMAIL)) {
$token = $usuarioSistema->gerarToken($professor->pk_usuario, Kernel_Models_TiposUsuario::TIPO_PROFESSOR);
if ($token) {
echo "Enviando para {$professor->nome}({$emailDestino}){$professor->pk_usuario_professor}<br>)";
$mail->mensagemDeModelo(array('titulo' => 'Olá ' . $professor->nome, 'subtitulo' => 'Este é o seu resumo semanal', 'conteudo' => 'Clique <a href="' . base_url() . 'usuario/auth/verificar_acesso/' . $token . '?pagina=' . base_url() . 'agendas/professor/meu_resumo_semanal/' . '">aqui</a> para ver o resumo das suas atividades '));
if ($constaEnvio->enviar($professor->nome, $emailDestino, 'Agenda semanal do professor', $mail->getMensagem())) {
echo 'Email enviado com sucesso<br>';
} else {
echo 'Falha ao enviar o e-mail para ' . $professor->nome . '<br>' . $constaEnvio->getErros() . '<br>';
}
}
}
}
}
示例3: _sendNotification
/**
* Send notification to admin if need
* @param $fromCheckPointTime
* @return bool
*/
private function _sendNotification($fromCheckPointTime)
{
if (!Yii::app()->params['csb']['notifyAdmin'] || empty(Yii::app()->params['csb']['adminEmail'])) {
return;
}
// send log of blocked users for last period
$lockedUsers = CsbLog::model()->findAll('create_time > :createTime AND type = :type', array(':createTime' => $fromCheckPointTime, ':type' => CsbLog::TYPE_LOCK));
if (!$lockedUsers) {
$this->_verbose("There's no new locked IPs");
return false;
}
$notification = 'Some users were blocked. Check Time ' . date('Y-m-d H:i:s') . '<br /><br />
<table cellpadding="5px" cellspacing="5px">
<tr>
<th>IP</th>
<th>Block Time</th>
<th>Block Till Time</th>
<th>User</th>
<th>Details</th>
</tr>';
foreach ($lockedUsers as $row) {
$notification .= '<tr>
<td>' . long2ip($row->ip) . '</td>
<td>' . $row->create_time . '</td>
<td>' . $row->till_time . '</td>
<td>' . $row->user_id . '</td>
<td>' . $row->details . '</td>
</tr>';
}
$notification .= '</table>';
$mail = new Mail();
$mail->setSubject('Some users were blocked')->setBodyHtml($notification)->addTo(Yii::app()->params['csb']['adminEmail'])->send();
$this->_verbose("Email was sent to admin", null, self::VERBOSE_INFO);
}
示例4: send
public function send()
{
if (isset($this->request->post['email']) && $this->request->post['email'] && isset($this->request->post['comments']) && $this->request->post['comments']) {
$this->load->language('common/maintenance');
$data['maintenance_type'] = $type = $this->config->get('config_maintenance_type') ? 'building' : 'maintenance';
$data['maintenance_title'] = $this->language->get('heading_title_' . $type);
$html = 'E-mail: <b>' . $this->request->post['email'] . '</b><br />' . 'Comentário: <b>' . $this->request->post['comments'] . '</b>';
if (!preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $this->request->post['email'])) {
exit('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> E-mail Inválido!</div>');
}
$mail = new Mail($this->config->get('config_mail'));
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['email']);
$mail->setSubject($data['maintenance_title'] . ' - ' . $this->config->get('config_name'));
$mail->setHtml($html);
$mail->setText(html_entity_decode(strip_tags($html), ENT_QUOTES, 'UTF-8'));
if ($mail->send()) {
exit('<div class="alert alert-success"><i class="fa fa-check-circle"></i> Informações enviadas com sucesso!</div>');
} else {
exit('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> Erro ao enviar!</div>');
}
} else {
exit('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> E-mail ou comentário não informado!</div>');
}
}
示例5: createRequest
/**
* Create new request and sends email to user
* @static
* @param string Mail adress
* @throws MailFailureException, UserNotFoundException
*/
public static function createRequest($mail)
{
LostPW::cleanUp();
$user = User::find('email', $mail);
if ($user == NULL) {
throw new UserNotFoundException();
}
// Delete old requests
$sql = System::getDatabase()->prepare('DELETE FROM lostpw WHERE user_ID = :uid');
$sql->execute(array(':uid' => $user->uid));
// Create new request
$hash = LostPW::createHash();
$sql = System::getDatabase()->prepare('INSERT INTO lostpw (user_ID, hash, time) VALUES (:uid, :hash, :time)');
$sql->execute(array(':uid' => $user->uid, ':hash' => $hash, ':time' => time()));
// Send Mail
$content = new Template();
$content->assign('link', Router::getInstance()->build('AuthController', 'lostpw_check', array('hash' => $hash)));
$content->assign('user', $user);
$content->assign('title', System::getLanguage()->_('LostPW'));
// Determine template file
$tpl = 'mails/lostpw.' . LANGUAGE . '.tpl';
foreach ($content->getTemplateDir() as $dir) {
$file = 'mails/lostpw.' . $user->lang . '.tpl';
if (file_exists($dir . $file)) {
$tpl = $file;
break;
}
}
$mail = new Mail(System::getLanguage()->_('LostPW'), $content->fetch($tpl), $user);
$mail->send();
}
示例6: actionWrite
public function actionWrite()
{
if (isset($_GET["reply"])) {
$reply = Mail::model()->with("buddy")->findByPk((int) $_GET["reply"], "t.user_id = :user_id", array(":user_id" => Yii::app()->user->id));
$reply->setSeen();
} else {
$reply = null;
}
$message = new Mail();
if ($reply) {
$message->sendTo = $reply->buddy->login;
if (preg_match('/^Re: (.*)$/', $reply->subj, $res)) {
$subj = "Re[1]: {$res[1]}";
} elseif (preg_match('/^Re\\[(\\d+)\\]: (.*)$/', $reply->subj, $res)) {
$subj = "Re[" . ($res[1] + 1) . "]: " . $res[2];
} else {
$subj = "Re: {$reply->subj}";
}
$message->subj = $subj;
} elseif (isset($_GET["to"])) {
$message->sendTo = trim(strip_tags($_GET["to"]));
}
if (isset($_POST["Mail"])) {
$message->setAttributes($_POST["Mail"]);
if ($message->send()) {
Yii::app()->user->setFlash("success", "Письмо отправлено " . $message->buddy->ahref);
$this->redirect("/my/mail");
}
}
if (!$reply) {
$buddies = User::model()->findAll(array("select" => array("t.id", "t.login", "t.sex", "t.upic"), "join" => "RIGHT JOIN mail ON t.id = mail.buddy_id", "condition" => "mail.user_id = :user_id", "group" => "t.id", "order" => "COUNT(*) DESC", "limit" => 20, "params" => array(":user_id" => Yii::app()->user->id)));
$this->side_view = array("write_side" => array("message" => $message, "buddies" => $buddies));
}
$this->render("write", array("message" => $message, "reply" => $reply));
}
示例7: hookCommentPublished
/**
* Hook comment publishing
*
* @param object $Comment
* @param object $Post
* @param object $Parent
* @param object $ParentAuthor
*/
public function hookCommentPublished($Comment, $Post, $Parent = NULL, $ParentAuthor = NULL)
{
// If you post comment to your post
if ($Post->aid != $Comment->aid) {
$replace = array('$user_link%' => $this->user->getLink(), '%user_name%' => $this->user->getName(), '%post_link%' => $Post->getLink(), '%post_name%' => $Post->name, '%comment%' => $Comment->body, '%reply_link%' => $Post->getLink() . '#comment-' . $Comment->id);
$mail = new Mail(array('name' => 'comment.post', 'subject' => t('New comment to your post', 'Mail.templates'), 'body' => str_replace(array_keys($replace), array_values($replace), t('User <a href="%user_link%">%user_name%</a> has published a comment to your post <a href="%post_link%">"%post_name%"</a>:
<p><i>%comment%</i></p>
<p><a href="%reply_link%">Reply →</a></p>'))));
if ($PostAuthor = user($Post->aid)) {
$mail->to($PostAuthor->email);
$mail->send();
}
}
/**
* If you reply and not to yourself
*/
if ($Parent && $Parent->aid != $this->user->id) {
$replace = array('$user_link%' => $this->user->getLink(), '%user_name%' => $this->user->getName(), '%post_link%' => $Post->getLink(), '%post_name%' => $Post->name, '%comment%' => $Comment->body, '%reply_link%' => $Post->getLink() . '#comment-' . $Comment->id);
$mail = new Mail(array('name' => 'comment.reply', 'subject' => t('Reply for your comment', 'Mail.templates'), 'body' => str_replace(array_keys($replace), array_values($replace), t('User <a href="%user_link%">%user_name%</a> has answered for you comment to post <a href="%post_link%">"%post_name%"</a>:
<p><i>%comment%</i></p>
<p><a href="%reply_link%">Reply →</a></p>', 'Mail.templates'))));
$mail->to($ParentAuthor->email);
$mail->send();
}
unset($mail);
}
示例8: testRender
/**
* @covers Xoops\Form\Mail::render
*/
public function testRender()
{
$value = $this->object->render();
$this->assertTrue(is_string($value));
$this->assertTrue(false !== strpos($value, '<input'));
$this->assertTrue(false !== strpos($value, 'type="email"'));
}
示例9: postSaveadd
public function postSaveadd()
{
$cre = ['name' => Input::get('name'), 'email' => Input::get('email'), 'enquiry' => Input::get('enquiry'), 'message' => Input::get('message')];
$rules = ['name' => 'required', 'email' => 'required|email', 'enquiry' => 'required|not_in:0', 'message' => 'required'];
$validator = Validator::make($cre, $rules);
if ($validator->passes()) {
require app_path() . '/mail.php';
require app_path() . '/libraries/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail_text = new Mail();
$mail->isMail();
$mail->setFrom('info@corperlife.com', 'Corper Life');
$mail->addAddress('questions@corperlife.com');
$mail->addAddress('vishu.iitd@gmail.com');
$mail->isHTML(true);
$mail->Subject = "Advertisement Request | Corper Life";
$mail->Body = $mail_text->advert(Input::get("name"), Input::get("email"), Input::get("enquiry"), Input::get("phone"), Input::get("message"));
if (!$mail->send()) {
return Redirect::Back()->with('failure', 'Mailer Error: ' . $mail->ErrorInfo);
} else {
return Redirect::Back()->with('success', 'Your enquiry has been submitted. We will respond to it asap.');
}
} else {
return Redirect::Back()->withErrors($validator)->withInput();
}
}
示例10: notifyNewUser
function notifyNewUser($address, $username, $logname, $logpwd)
{
global $AppUI, $dPconfig;
$mail = new Mail();
if ($mail->ValidEmail($address)) {
if ($mail->ValidEmail($AppUI->user_email)) {
$email = $AppUI->user_email;
} else {
$email = 'dotproject@' . $AppUI->cfg['site_domain'];
}
$name = $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
$body = $username . ',
An access account has been created for you in our dotProject project management system.
You can access it here at ' . $dPconfig['base_url'] . '
Your username is: ' . $logname . '
Your password is: ' . $logpwd . '
This account will allow you to see and interact with projects. If you have any questions please contact us.';
$mail->From('"' . $name . '" <' . $email . '>');
$mail->To($address);
$mail->Subject('New Account Created - dotProject Project Management System');
$mail->Body($body);
$mail->Send();
}
}
示例11: actionIndex
public function actionIndex()
{
if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) {
$this->redirect(Yii::app()->homeUrl);
}
$this->pageTitle = Yii::t('title', 'Send mail');
$model = new Mail();
if (isset($_POST['Mail'])) {
$model->attributes = $_POST['Mail'];
$player_id = Players::model()->find('name = "' . $model->player_name . '"');
if ($player_id->online == 1) {
Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Error - You must first log out of the game server.') . '</div>');
}
$criteria = new CDbCriteria();
$criteria->select = 'MAX(mail_unique_id) as mail_unique_id';
$last_mail_id = Mail::model()->find($criteria);
$model->mail_unique_id = $last_mail_id->mail_unique_id + 1;
$model->mail_recipient_id = $player_id->id;
$model->sender_name = 'ServerWebsite';
$model->mail_title = $model->mail_title;
$model->mail_message = $model->mail_message . "\n\nThis has been sent via our server website. Please, do not reply.";
$model->unread = 1;
// Fallenfate - Add function to send kinah to players.
if ($model->item_count != NULL || $model->item_count != "") {
$model->attached_item_id = 0;
$model->attached_kinah_count = $model->item_count;
}
$model->express = 1;
if ($model->save(false)) {
Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Mail sent!') . '</div>');
$this->refresh();
}
}
$this->render('/admin/mail', array('model' => $model));
}
示例12: test_send_from_properties
function test_send_from_properties()
{
$msg = new Mail();
$mail_to = 'to_one@test.fr; to_two@test.fr';
$mail_from = 'from_one@test.fr; from_two@test.fr';
$mail_objet = 'objet';
$mail_contents = 'contents';
$ret = $msg->send_from_properties($mail_to, $mail_objet, $mail_contents, $mail_from);
if (ereg("127.0.0.1", $_SERVER['SERVER_ADDR'])) {
self::assertFalse($ret);
} else {
self::assertTrue($ret);
}
$ret = $msg->send_from_properties($mail_to, $mail_objet, $mail_contents, $mail_from);
if (ereg("127.0.0.1", $_SERVER['SERVER_ADDR'])) {
self::assertFalse($ret);
} else {
self::assertTrue($ret);
}
$mail_sender = 'visiteur';
$ret = $msg->send_from_properties($mail_to, $mail_objet, $mail_contents, $mail_from, $mail_sender);
if (ereg("127.0.0.1", $_SERVER['SERVER_ADDR'])) {
self::assertFalse($ret);
} else {
self::assertTrue($ret);
}
$mail_from = 'from_bidon';
$mail_sender = 'visiteur';
$ret = $msg->send_from_properties($mail_to, $mail_objet, $mail_contents, $mail_from, $mail_sender);
self::assertFalse($ret);
}
示例13: solve_combats
/**
* résolution des combats (chargé depuis index.php)
**/
public function solve_combats()
{
// identification de l'attaquant et du défenseur
$attacker = new User($this->attacker_id);
$defender = new User($this->target_id);
// ... et de leur armée
$army_att = new Army($this->attacker_id, $this->id);
$army_def = new Army($this->target_id);
// affichage de l'armée attaquante
$mess_att = '';
foreach ($army_att->troops as $unit) {
if ($unit->quantity > 0) {
$mess_att .= '<li>' . $unit->quantity . ' ' . $unit->name . '</li>';
}
}
// affichage de l'armée en défence
$mess_def = '';
if ($army_def->total_units > 0) {
foreach ($army_def->troops as $unit) {
$mess_def .= '<li>' . $unit->quantity . ' ' . $unit->name . '</li>';
}
} else {
$mess_def .= "<li>Il n'y avait personne pour défendre cet empire</li>";
}
$message = "<table><tr>" . "<th style=\"width:50%\">Attaquant : {$attacker->pseudo}<br>flotte : {$army_att->total_units} unité(s)</th>" . "<th style=\"width:50%\">Défenseur : {$defender->pseudo}<br>flotte : {$army_def->total_units} unité(s)</th>" . "</tr><tr><td><ul>{$mess_att}</ul></td><td><ul>{$mess_def}</ul></td></tr>";
if ($army_def->total_units > 0) {
// résolution du combat en 6 tours (on boucle tant qu'il reste des unités à un joueur
$i = 0;
while ($i < 6 && $army_att->total_units > 0 && $army_def->total_units > 0) {
$i++;
// il faut temporiser les dégats de l'attaquant pour qu'il puisse attaquer de toute sa force
// car va lui détruire des unités dès sa première attaque
$dommages = $army_def->total_damage;
$def_res = $army_def->split_damage($army_att->total_damage);
$att_res = $army_att->split_damage($dommages);
$message .= "<tbody><tr><th colspan=\"2\">Tour {$i}</th></tr><tr><td>{$att_res}</td><td>{$def_res}</td></tr></tbody>";
}
}
// résultat du combat
if ($army_def->total_units <= 0) {
$available = round($defender->ressources / 3);
$can_take = round($army_att->total_life);
$amount = $available - $can_take > 0 ? $can_take : $available;
$attacker->increase_ressource($amount);
$defender->increase_ressource(-$amount);
$result = 'Vainqueur : ' . $attacker->pseudo . '<br>Ressources pillées : ' . $amount;
} elseif ($army_att->total_units <= 0) {
$result = 'Vainqueur : ' . $defender->pseudo;
} else {
$result = 'Aucun vainqueur';
}
$message .= "<tr><td colspan='2'>{$result}</td></tr></table>";
$this->reset_army();
// envoi les rapports de combats
$mail = new Mail();
$mail->send_mail($attacker->id, $message, 'Rapport de combat (' . $defender->pseudo . ')');
// on changer uniquement le destinataire et on le renvoi
$mail->recipient = $defender->id;
$mail->add();
}
示例14: inscription
function inscription()
{
$erreur_array = array('name' => -1, 'description' => -1, 'contenu' => -1, 'from' => -1, 'to' => -1);
$erreur = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$array_user = $this->postLogin($erreur, $erreur_array);
$nb = $this->userExist(array('email' => $array_user['user']['email']));
if (!$erreur && !$nb) {
$array_user['user']['is_verified'] = uniqid();
$userDao = new UserDao(new User($array_user['user']));
$userDao->create();
//die(var_dump($array_services));
$iduser = $userDao->getLastID();
$array_user['adresse']['id_user'] = $iduser;
$adresseDao = new AdresseDao(new Adresse($array_user['adresse']));
$adresseDao->create();
$mail = new Mail();
$result = $mail->sendMailActivation('support@rp2m.com', $array_user['user']['email'], $array_user['user']['prenom'], $array_user['user']['is_verified']);
if ($result['send']) {
$this->set(array('success' => '1'));
$this->render('inscription');
}
} elseif ($nb) {
$this->set(array('success' => '2'));
$this->render('inscription');
} elseif ($erreur) {
$this->render('inscription');
}
}
$this->set(array('success' => '0'));
$this->render('inscription');
}
示例15: register
/**
* User register
* @global type $cart
* @param type $registerInfo
* @return boolean
* @author hujs
*/
public function register($registerInfo)
{
$this->load->model('account/customer');
$this->model_account_customer->addCustomer($registerInfo);
$this->language->load('mail/account_create');
$subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
$message = sprintf($this->language->get('text_welcome'), $this->config->get('config_name')) . "\n\n";
if (!$this->config->get('config_customer_approval')) {
$message .= $this->config->get('text_login') . "\n";
} else {
$message .= $this->config->get('text_approval') . "\n";
}
$message .= HTTPS_SERVER . 'index.php?route=account/login' . "\n\n";
$message .= $this->language->get('text_services') . "\n\n";
$message .= $this->language->get('text_thanks') . "\n";
$message .= $this->language->get('config_name');
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($registerInfo['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_name'));
$mail->setSubject($subject);
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
return true;
}