當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sendEmail函數代碼示例

本文整理匯總了PHP中sendEmail函數的典型用法代碼示例。如果您正苦於以下問題:PHP sendEmail函數的具體用法?PHP sendEmail怎麽用?PHP sendEmail使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sendEmail函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: forgotpassword

 public function forgotpassword()
 {
     $data = '';
     $post = $this->input->post();
     if ($post) {
         $error = array();
         $e_flag = 0;
         if (!valid_email(trim($post['email'])) && trim($post['email']) == '') {
             $error['email'] = 'Please enter email.';
             $e_flag = 1;
         }
         if ($e_flag == 0) {
             $where = array('email' => trim($post['email']), 'role' => 'admin');
             $user = $this->common_model->selectData(ADMIN, '*', $where);
             if (count($user) > 0) {
                 $newpassword = random_string('alnum', 8);
                 $data = array('password' => md5($newpassword));
                 $upid = $this->common_model->updateData(ADMIN, $data, $where);
                 $emailTpl = $this->load->view('email_templates/admin_forgot_password', array('username' => $user[0]->name, 'password' => $newpassword), true);
                 $ret = sendEmail($user[0]->email, SUBJECT_LOGIN_INFO, $emailTpl, FROM_EMAIL, FROM_NAME);
                 if ($ret) {
                     $flash_arr = array('flash_type' => 'success', 'flash_msg' => 'Login details sent successfully.');
                 } else {
                     $flash_arr = array('flash_type' => 'error', 'flash_msg' => 'An error occurred while processing.');
                 }
                 $data['flash_msg'] = $flash_arr;
             } else {
                 $error['email'] = "Invalid email address.";
             }
         }
         $data['error_msg'] = $error;
     }
     $this->load->view('index/forgotpassword', $data);
 }
開發者ID:niravpatel2008,項目名稱:ubiquitous-octo-tatertot,代碼行數:34,代碼來源:index.php

示例2: add_comment

function add_comment($moderator_email)
{
    $caller = strtolower($_POST["url"]);
    //$_SERVER['HTTP_REFERER'];
    $filename = md5($caller);
    $abs_comment_file = realpath('.') . '/' . $filename . '.xml';
    $date_value = time();
    $comment_id = $date_value . '-' . rand(1, 100000000);
    $author_value = processText($_POST["name"]);
    $subject_value = trim(processText($_POST["subject"]));
    $msg_value = processText($_POST["message"]);
    $email = processText($_POST["email"]);
    $site = processText($_POST["site"]);
    $title = processText($_POST["title"]);
    $parent_id = processText($_POST["id"]);
    $dom_id = processText($_POST["domid"]);
    $moderate = processText($_POST["moderate"]);
    // 0 No moderate, 1: waiting for moderate 2: trash 3: spamn 4: approved
    $max_reply = intval(processText($_POST["max"]));
    $secured = empty($_SERVER["HTTPS"]) ? '' : $_SERVER["HTTPS"] == "on" ? "s" : "";
    $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $secured;
    $ec_path = $protocol . '://' . $_SERVER['HTTP_HOST'] . processText($_POST["path"]);
    if (empty($parent_id)) {
        $parent_id = null;
    }
    $ip = $_SERVER["REMOTE_ADDR"];
    $ret = addComment($abs_comment_file, $caller, $title, $dom_id, $comment_id, $date_value, $author_value, $subject_value, $email, $site, $msg_value, $ip, $moderate, $parent_id, $max_reply);
    $msg_value = str_replace(array("\r", "\n"), "<br />", $msg_value);
    echo json_encode(array("id" => $comment_id, "comment" => '<li class="ec-comment" id="' . $comment_id . '">' . '   <div class="avatar"></div>' . '   <span class="user-name author">' . $author_value . '</span> <br/>' . '   <span class="comment-html">' . (empty($subject_value) ? '' : '      <strong>' . $subject_value . '</strong><br /><br />') . $msg_value . '   </span><br/>' . '   <span class="comment-time">' . ago(time() - $date_value * 1) . '</span><br/>' . ($ret ? '   <button name="reply" id="reply_' . $comment_id . '">Reply</button>' : "") . '</li>'));
    // send email to moderator
    if ($moderate == "1") {
        $body = 'A new comment is waiting for your approval:<br /><br />' . 'Author:' . $author_value . '(IP: ' . $ip . ')<br/>' . 'Email:' . $email . '<br/>' . 'URL:' . $site . '<br/>' . 'Subject:' . $subject_value . '<br/>' . 'Whois:<a href="http://whois.arin.net/rest/ip/' . $ip . '" target="_blank">http://whois.arin.net/rest/ip/' . $ip . '</a><br/>' . 'Comment:<br/>' . '<blockquote>' . $msg_value . '</blockquote><br/>' . 'To moderate this message, click <a href="' . $ec_path . 'ec-dashboard.html">' . $ec_path . 'ec-dashboard.html</a><br/>' . '<br/>' . 'Thanks for choosing EastComment<br/><br/>' . '<a href="http://www.jswidget.com/lab/easy-comment.html" target="_blank">http://www.jswidget.com/lab/easy-comment.html</a>';
        sendEmail($moderator_email, $body);
    }
}
開發者ID:rahul1205,項目名稱:summerproject,代碼行數:35,代碼來源:ec-comment.php

示例3: register

 public function register()
 {
     //完成注冊,注冊完成發送一封激活郵件
     if (IS_POST) {
         $model = new \Model\UserModel();
         if ($data = $model->create()) {
             $validate = uniqid();
             $data['validate'] = $validate;
             if ($model->add($data)) {
                 //注冊成功,發送郵件激活
                 $email = I('post.email');
                 $title = '注冊用戶,完成激活';
                 $url = "http://web.com/index.php/Home/User/active/key/" . $validate . "/email/" . $email;
                 $content = "親,您已注冊成功,趕緊激活使用吧!請<a href='{$url}'>單擊激活</a>";
                 if (sendEmail($email, $content, $title)) {
                     $this->success('郵件發送成功,請盡快激活', U('login'), 1);
                     exit;
                 }
                 $this->error('發送郵件失敗,請重新注冊');
             }
             $this->error('注冊失敗');
         }
         $this->error($model->getError());
     }
     $this->display();
 }
開發者ID:VenusGrape,項目名稱:hymall,代碼行數:26,代碼來源:UserController.class.php

示例4: sendUserLogsViaMail

function sendUserLogsViaMail($classID)
{
    $conn = getMainConnection();
    $query = "SELECT * FROM info WHERE ID = '" . $classID . "'";
    $result = mysql_query($query);
    $numrows = mysql_affected_rows();
    if ($numrows == 1) {
        $member = mysql_fetch_array($result);
        if ($member['activeflag'] != 0) {
            getTemporaryConnection($member['databasename']);
        }
    }
    $query = "SELECT * FROM login_logs WHERE lastlogin <= '" . time() . "' AND lastlogin >= '" . (time() - 86400) . "'";
    $result = mysql_query($query);
    $mail_string = '';
    while ($member = mysql_fetch_array($result)) {
        $time = date("F j, Y, g:i a", $member['lastlogin']);
        $user = getUser($member['userID'])->getName();
        $mail_string .= $user . ' logged in at ' . $time . ' from the ip ' . $member['ip'] . '<br />';
    }
    //echo $mail_string;
    $toEmail = 'acechemistry2@gmail.com';
    $toName = 'Ace Chemistry';
    $fromEmail = 'noreply@knowledgeportal.in';
    $fromName = 'My Class - Knowledge Portal';
    $subject = 'Staff Login Logs : ' . date("d-m-Y");
    $body = 'Staff Login Logs <hr /><br />' . $mail_string;
    $flag = sendEmail($toEmail, $toName, $fromEmail, $fromName, $subject, $body, '');
    return $flag;
}
開發者ID:harshselani,項目名稱:My-Class,代碼行數:30,代碼來源:emailfunctions.php

示例5: addUser

function addUser($email, $first_name, $last_name, $phone, $address, $town, $organization, $country, $zip, $october6, $october7, $october8, $october9, $october10, $msg_email, $msg_phone)
{
    $db = getDb();
    //$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
    try {
        $stmt = $db->prepare('INSERT INTO users (email, first_name, last_name, phone, address, town, organization, country, zip, october6, october7, october8, october9, october10, msg_email, msg_phone)
							VALUES ("' . $email . '", "' . $first_name . '", "' . $last_name . '", "' . $phone . '", "' . $address . '", "' . $town . '", "' . $organization . '", "' . $country . '", "' . $zip . '", ' . $october6 . ', ' . $october7 . ', ' . $october8 . ', ' . $october9 . ', ' . $october10 . ', ' . $msg_email . ', ' . $msg_phone . ')');
        //	$stmt = $db->prepare('INSERT INTO users (email, first_name, last_name, phone, address, town, organization, country, zip, october6, october7, october8, october9, october10, msg_email, msg_phone)
        //							VALUES ("' . $email .'", "' . $first_name .'", "' . $last_name .'", "' . $phone .'", "' . $address .'", "' . $town .'", "' . $organization .'", "' . $country .'", "' . $zip .'", true, false, true, true, false, true, true)');
        /*$stmt->bindValue(':email', $email, PDO::PARAM_STR);
        	$stmt->bindValue(':first_name', $first_name, PDO::PARAM_STR);
        	$stmt->bindValue(':last_name', $last_name, PDO::PARAM_STR);
        	$stmt->bindValue(':phone', $phone, PDO::PARAM_STR);
        	$stmt->bindValue(':address', $address, PDO::PARAM_STR);
        	$stmt->bindValue(':town', $town, PDO::PARAM_STR);
        	$stmt->bindValue(':organization', $organization, PDO::PARAM_STR);
        	$stmt->bindValue(':country', $country, PDO::PARAM_STR);
        	$stmt->bindValue(':zip', $zip, PDO::PARAM_STR);
        	$stmt->bindValue(':october6', $october6, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october7', $october7, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october8', $october8, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october9', $october9, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october10', $october10, PDO::PARAM_STR);
        	$stmt->bindValue(':msg_email', $msg_email, PDO::PARAM_BOOL);
        	$stmt->bindValue(':msg_phone', $msg_phone, PDO::PARAM_BOOL); */
        $stmt->execute();
        // TODO: This does not work, please fix
    } catch (PDOException $e) {
        //		echo $e->getMessage();
    }
    sendEmail($first_name, $last_name, $october6, $october7, $october8, $october9, $october10, $email);
    //	print_r($db->errorInfo());
}
開發者ID:CarlTaylor1989,項目名稱:sap-intel-vrst,代碼行數:33,代碼來源:register.php

示例6: registration

  function registration()
  {
      $this->loadModel('User');
      $this->loadModel('Role');
      if ($this->request->is('post')) {
          $this->User->set($this->request->data);
          if ($this->User->validates()) {
              //$this->request->data['User']['password'] = md5($this->request->data['User']['password']);
              $mail_data = $this->User->save($this->request->data);
              // send mail :
              $from = $mail_data['User']['email'];
              $subject = "New technician registration";
              $user_name = $mail_data['User']['name'];
              $email_user = $mail_data['User']['email'];
              $password = $this->request->data['User']['password'];
              $role_id = $mail_data['User']['role_id'];
              $to = array('info@totalcableusa.com', 'sattar.kuet@gmail.com', 'rjasoft@gmail.com');
              $mail_content = __('Name:', 'beopen') . $user_name . PHP_EOL . __('Email:', 'beopen') . $email_user . PHP_EOL . __('Password:', 'beopen') . $password . PHP_EOL . __('Role Id:', 'beopen') . $role_id . PHP_EOL . __($url = Router::url(array("controller" => "users", "action" => "login"), true));
              sendEmail($from, $user_name, $to, $subject, $mail_content);
              // End send mail
              $msg = '<div class="alert alert-success">
 <button type="button" class="close" data-dismiss="alert">&times;</button>
 <strong> User Created succeesfully </strong>
 </div>';
          } else {
              $msg = $this->generateError($this->User->validationErrors);
          }
          $this->Session->setFlash($msg);
          // return $this->redirect('create');
      }
      $this->set('roles', $this->Role->find("list"));
  }
開發者ID:sattar-kuet,項目名稱:totalCable,代碼行數:32,代碼來源:UsersController111215.php

示例7: _request_new_password

function _request_new_password()
{
    if (isset($_POST['email'])) {
        $user = new User(getdbh());
        $ID = $user->checkEmail($_POST['email']);
        if (isset($ID['ID'])) {
            $setToken = $user->setRecover($ID['ID'], $_POST['email']);
            if ($setToken != false) {
                $body = 'Pentru a schimba parola apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/recover_password/' . $setToken . '"> AICI </a>';
                if (sendEmail('Schimbare parola', $body, 'ulbsPlatform@ebs.ro', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de resetare a parolei a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul nu a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Tokenul este gresit sau au trecut mai mult de 2 zile de la cererea de recuperare parola";
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Acest user nu exista";
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    } else {
        redirect('main/index');
    }
}
開發者ID:laiello,項目名稱:ebs-academy-at-ulbs-2014,代碼行數:28,代碼來源:request_new_password.php

示例8: main

function main($contactForm)
{
    // Checks if something was sent to the contact form, if not, do nothing
    if (!$contactForm->isDataSent()) {
        return;
    }
    // validates the contact form and initialize the errors
    $contactForm->validate();
    $errors = array();
    // if the contact form is not valid...
    if (!$contactForm->isValid()) {
        // gets the error in the array $errors
        $errors = $contactForm->getErrors();
    } else {
        // if the contact form is valid...
        try {
            // send the email created with the contact form
            $result = sendEmail($contactForm);
            // after the email is sent, redirect and "die".
            // We redirect to prevent refreshing the page which would resend the form
            header("Location: ./success.php");
            die;
        } catch (Exception $e) {
            // an error occured while sending the email.
            // Log the error and add an error message to display to the user.
            error_log('An error happened while sending email contact form: ' . $e->getMessage());
            $errors['oops'] = 'Ooops! an error occured while sending your email! Please try again later!';
        }
    }
    return $errors;
}
開發者ID:chavezjude7,項目名稱:Jude-Chavez,代碼行數:31,代碼來源:composer.php

示例9: _newUser

function _newUser()
{
    $user = new User(getdbh());
    $email = $user->checkEmail($_POST['email']);
    if (isset($email['ID'])) {
        $data['msg'][] = " Acest email nu este disponibil! Va rugam alegeti altul!";
        $data['redirect'][] = 'main/new';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $result = $user->addUser($_POST['email'], $_POST['password1'], $_POST['nume'], $_POST['prenume']);
        if ($result > 0) {
            $setToken = $user->newUserToken($result);
            if ($setToken != false) {
                $body = 'Pentru a activa contul apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/newUserToken/' . $setToken . '"> AICI </a>';
                if (sendEmail('Email confirmare cont', $body, 'ulbsPlatform@ebs.ro', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de confirmare cont a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul cu linkul de confirmare nu a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Eroare la generarea tokenului";
                $data['redirect'][] = 'main/index';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Eroare la crearea contului!";
            $data['redirect'][] = 'main/index';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    }
}
開發者ID:laiello,項目名稱:ebs-academy-at-ulbs-2014,代碼行數:35,代碼來源:newUser.php

示例10: __construct

 function __construct()
 {
     $guid = getInput("guid");
     $reply = getInput("reply");
     if (!$reply) {
         new SystemMessage("Message body cannot be left empty.");
         forward();
     }
     $message = getEntity($guid);
     $to = getLoggedInUserGuid() == $message->to ? $message->from : $message->to;
     $from = getLoggedInUserGuid();
     $to_user = getEntity($to);
     $from_user = getEntity($from);
     $message_element = new Messageelement();
     $message_element->message = $reply;
     $message_element->to = $to;
     $message_element->from = $from;
     $message_element->container_guid = $guid;
     $message_element->save();
     $link = getSiteURL() . "messages";
     notifyUser("message", $to, getLoggedInUserGuid(), $to);
     sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true));
     new SystemMessage("Your message has been sent.");
     forward("messages/" . $message->guid);
 }
開發者ID:socialapparatus,項目名稱:socialapparatus,代碼行數:25,代碼來源:MessageReplyActionHandler.php

示例11: add

 /**
  * subscribe a user
  * @param object http request
  * @return bool
  */
 public function add(\applications\modules\users\entities\usersEntity $user)
 {
     //check if the email exists
     if (!$this->checkEmailExists($user->getEmail())) {
         if (ENABLE_MAIL_REGISTRATION == 1) {
             $user->setLevel(rand(100000, 999999));
             $user->setActive(0);
         } else {
             $user->setLevel(1);
             $user->setActive(1);
         }
         //try to save in db
         if ($this->currentManager->save($user)) {
             //send email
             $dest = $user->getEmail();
             $subject = WEBSITE_TITLE . ' - Activez votre compte';
             $msg = '<body><head></head><body><div style="width : 100%;height : 550px;padding : 25px;background-color : #EFEFEF"><div style="padding : 20px;width : 450px;margin-left: auto;margin-right: auto;background-color: #ffffff !important;box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.2);"><h2 style="color: #428bca !important;">Bonjour ' . $user->getName() . ' et bienvenue</h2><hr/>Votre compte est activ&eacute;, connectez-vous et rejoignez les nombreux ateliers propos&eacute;s.<br/><br/>Si vous rencontrez le moindre probl&egrave;me, n&#39;h&eacute;sitez pas &agrave; nous contacter &agrave; l&#39;adresse suivante : contact.agoraexmachina@gmail.com<br/><br/><br/><br/><p style="color: #555555 !important;">L&#39;&eacute;quipe AGORA Ex Machina.</p></div></div></body></body>';
             try {
                 sendEmail($dest, $subject, $msg);
                 return true;
             } catch (\Exception $e) {
                 \library\handleErrors::setErrors($this->errorSendEmail);
             }
         } else {
             \library\handleErrors::setErrors($this->errorSaveInDb);
         }
     } else {
         \library\handleErrors::setErrors($this->errorExistingElement);
     }
     return false;
 }
開發者ID:ThomasSchweizer,項目名稱:agoraexmachina,代碼行數:36,代碼來源:usersService.class.php

示例12: notificaPrazoUsuario

function notificaPrazoUsuario()
{
    if (acesso()) {
        sendEmail();
    }
    return true;
}
開發者ID:roquebrasilia,項目名稱:sgdoc-codigo,代碼行數:7,代碼來源:notificar_prazo_usuario.php

示例13: process

 public function process()
 {
     $content = nl2br($this->getElementValue('body'));
     $content .= '<br /><br /><small>This is NOT an automated email, a human wrote this email and sent it to you directly from lanlist.org. We try not to spam our users and hope you found this email useful. If you REALLY hate us and want to stop receiving email from us then login to http://lanlist.org and remove your email address from your user profile. You should be able to reply to this email and talk to a human, or check http://lanlist.org/contact.php for our latest contact details. </small>';
     $subject = $this->getElementValue('subject');
     sendEmail($this->getElementValue('email'), $content, $subject, false);
     redirect('listUsers.php?', 'Email sent.');
 }
開發者ID:jamesread,項目名稱:lanlist.org,代碼行數:8,代碼來源:FormSendEmailToUser.php

示例14: sendEmail_log

function sendEmail_log($log_html_url)
{
    $to = "icerrr@rejh.nl";
    $subject = "Icerrr log";
    $message = "Hi,\n\nA new log has been uploaded:\n" . $log_html_url . "\n\nOr check: \nhttp://www.rejh.nl/icerrr/api/logs_users/read.php \n\nGreetings,\n\nIcerrr Mailer";
    $headers = 'From: noreply-icerrr@rejh.nl' . "\r\n" . 'Reply-To: noreply-icerrr@rejh.nl' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    sendEmail($to, $subject, $message, $headers, false);
}
開發者ID:FXDigitalNetworks,項目名稱:icerrr,代碼行數:8,代碼來源:s.functions.php

示例15: executeSendsubmit

 function executeSendsubmit()
 {
     global $template, $WebBaseDir, $ClassDir, $controller, $i18n, $ActiveOption, $LU;
     require_once $ClassDir . "SendEmail.php";
     $arr = sendEmail(trim($_POST['to']), $LU->getProperty("email"), $LU->getProperty("handle"), $LU->getProperty("email"), trim($_POST['title']), trim($_POST['content']), trim($_POST['content']));
     $template->setFile(array("MAIN" => "apf_mail_write.html"));
     $template->setBlock("MAIN", "edit_block");
     $template->setVar(array("WEBDIR" => $WebBaseDir, "SENT_MSG" => "<h2>" . $arr["msg"] . "</h2>", "SUCCESS_CLASS" => "save-ok", "TEXTAREACONTENT" => textareaTag("content", "", true), "DOACTION" => "sendsubmit"));
 }
開發者ID:BackupTheBerlios,項目名稱:flushcms,代碼行數:9,代碼來源:MailSender.class.php


注:本文中的sendEmail函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。