Example #1
3
 public function sendMail($to, $subject, $body, $files = array())
 {
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->SMTPDebug = 2;
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = EMAIL_SMTPSECURE;
     $mail->Host = EMAIL_SMTPHOST;
     $mail->Port = EMAIL_SMTPPORT;
     $mail->Username = EMAIL_SMTPUSER;
     $mail->Password = EMAIL_SMTPPASSWORD;
     $mail->SetFrom(EMAIL_SENDER, EMAIL_SENDERNAME);
     $mail->Subject = $subject;
     foreach ($files as $file) {
         $mail->AddAttachment($file, basename($file));
     }
     $mail->MsgHTML($body);
     $mail->AddAddress($to);
     ob_start();
     $ok = $mail->Send();
     $ob = ob_get_contents();
     ob_end_clean();
     if (!$ok) {
         $this->error = $mail->ErrorInfo . "\n" . $ob;
         $this->processError();
     }
 }
Example #2
0
 /**
  * 构造函数
  * 
  * @access public
  * @param string $config['host'] SMTP 服务器
  * @param string $config['username']
  * @param string $config['password'] 
  * @return void
  */
 public function __construct($config)
 {
     if (file_exists('third_party/phpMailer/class.phpmailer.php') && file_exists('third_party/phpMailer/class.smtp.php')) {
         include 'third_party/phpMailer/class.phpmailer.php';
         include 'third_party/phpMailer/class.smtp.php';
     } else {
         throw new Exception('phpMailer lib not found.', 204);
     }
     $this->host = $config['host'];
     $this->userName = $config['username'];
     $this->password = $config['password'];
     $this->phpMailer = new PHPMailer();
     $this->phpMailer->CharSet = $this->charSet;
     $this->phpMailer->isSMTP();
     $this->phpMailer->SMTPDebug = $this->isDebug;
     $this->phpMailer->SMTPAuth = true;
     $this->phpMailer->Host = $this->host;
     $this->phpMailer->Port = $this->port;
     $this->phpMailer->Username = $this->userName;
     $this->phpMailer->Password = $this->password;
     $this->phpMailer->SetFrom(self::SENDFROMADDRESS, '纳米服务');
     $this->phpMailer->Subject = '你有新的通知信息';
     $this->phpMailer->AltBody = 'To view the message, please use an HTML compatible email viewer!';
     // optional, comment out and test
 }
 /**
  * Short description of method send
  *
  * @access public
  * @author Bertrand Chevrier, <*****@*****.**>
  * @return int
  */
 public function send()
 {
     $returnValue = (int) 0;
     foreach ($this->messages as $message) {
         if ($message instanceof tao_helpers_transfert_Message) {
             $this->mailer->SetFrom($message->getFrom());
             $this->mailer->AddReplyTo($message->getFrom());
             $this->mailer->Subject = $message->getTitle();
             $this->mailer->AltBody = strip_tags(preg_replace("/<br.*>/i", "\n", $message->getBody()));
             $this->mailer->MsgHTML($message->getBody());
             $this->mailer->AddAddress($message->getTo());
             try {
                 if ($this->mailer->Send()) {
                     $message->setStatus(tao_helpers_transfert_Message::STATUS_SENT);
                     $returnValue++;
                 }
                 if ($this->mailer->IsError()) {
                     if (DEBUG_MODE) {
                         echo $this->mailer->ErrorInfo . "<br>";
                     }
                     $message->setStatus(tao_helpers_transfert_Message::STATUS_ERROR);
                 }
             } catch (phpmailerException $pe) {
                 if (DEBUG_MODE) {
                     print $pe;
                 }
             }
         }
         $this->mailer->ClearReplyTos();
         $this->mailer->ClearAllRecipients();
     }
     $this->mailer->SmtpClose();
     return (int) $returnValue;
 }
Example #4
0
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
    require_once APPPATH . 'modules_core/mailer/helpers/phpmailer/class.phpmailer.php';
    $CI =& get_instance();
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsHtml();
    if ($CI->mdl_mcb_data->setting('email_protocol') == 'smtp') {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        if ($CI->mdl_mcb_data->setting('smtp_security')) {
            $mail->SMTPSecure = $CI->mdl_mcb_data->setting('smtp_security');
        }
        $mail->Host = $CI->mdl_mcb_data->setting('smtp_host');
        $mail->Port = $CI->mdl_mcb_data->setting('smtp_port');
        $mail->Username = $CI->mdl_mcb_data->setting('smtp_user');
        $mail->Password = $CI->mdl_mcb_data->setting('smtp_pass');
    } elseif ($CI->mdl_mcb_data->setting('email_protocol') == 'sendmail') {
        $mail->IsSendmail();
    }
    if (is_array($from)) {
        $mail->SetFrom($from[0], $from[1]);
    } else {
        $mail->SetFrom($from);
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    $to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
    foreach ($to as $address) {
        $mail->AddAddress($address);
    }
    if ($cc) {
        $cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
        foreach ($cc as $address) {
            $mail->AddCC($address);
        }
    }
    if ($bcc) {
        $bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
        foreach ($bcc as $address) {
            $mail->AddBCC($address);
        }
    }
    if ($attachment_path) {
        $mail->AddAttachment($attachment_path);
    }
    if ($mail->Send()) {
        if (isset($CI->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_success', $CI->lang->line('email_success'));
            return TRUE;
        }
    } else {
        if (isset($CI->this->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_error', $mail->ErrorInfo);
            return FALSE;
        }
    }
}
Example #5
0
 function Send()
 {
     $mail = new PHPMailer();
     $mail->CharSet = 'UTF-8';
     $mail->Host = $this->smtp['smtp_server'];
     $mail->Port = $this->smtp['smtp_port'];
     if ($this->smtp['smtp_enable']) {
         $mail->IsSMTP();
         $mail->Username = $this->smtp['smtp_usr'];
         $mail->Password = $this->smtp['smtp_psw'];
         $mail->SMTPAuth = $this->smtp['smtp_auth'] ? true : false;
     }
     if ($this->smtp['smtp_from_email']) {
         $mail->SetFrom($this->smtp['smtp_from_email'], $this->smtp['smtp_from_name']);
     } else {
         $mail->SetFrom($this->smtp['smtp_server'], $this->smtp['smtp_usr']);
     }
     if (is_array($this->to)) {
         foreach ($this->to as $key => $val) {
             $name = is_numeric($key) ? "" : $key;
             $mail->AddAddress($val, $name);
         }
     } else {
         $mail->AddAddress($this->to, $this->to_name);
     }
     if (!empty($this->smtp['smtp_reply_email'])) {
         $mail->AddReplyTo($this->smtp['smtp_reply_email'], $this->smtp['smtp_reply_name']);
     }
     if ($this->cc) {
         if (is_array($this->cc)) {
             foreach ($this->cc as $keyc => $valcc) {
                 $name = is_numeric($keyc) ? "" : $keyc;
                 $mail->AddCC($valcc, $name);
             }
         } else {
             $mail->AddCC($this->cc, $this->cc_name);
         }
     }
     if ($this->attach) {
         if (is_array($this->attach)) {
             foreach ($this->attach as $key => $val) {
                 $mail->AddAttachment($val);
             }
         } else {
             $mail->AddAttachment($this->attach);
         }
     }
     // 		$mail->SMTPSecure = 'ssl';
     $mail->SMTPSecure = "tls";
     $mail->WordWrap = 50;
     $mail->IsHTML($this->is_html);
     $mail->Subject = $this->subject;
     $mail->Body = $this->body;
     $mail->AltBody = "";
     // return $mail->Body;
     return $mail->Send();
 }
Example #6
0
 function send($o, $to, $from, $subject, $body, $headers)
 {
     $mail = new PHPMailer(true);
     $mail->IsSMTP();
     $mail->SMTPDebug = 0;
     // enables SMTP debug information (for testing)
     $mail->SMTPAuth = $this->api->getConfig("tmail/phpmailer/username", null) ? true : false;
     // enable SMTP authentication
     $mail->Host = $this->api->getConfig("tmail/smtp/host");
     $mail->Port = $this->api->getConfig("tmail/smtp/port");
     $mail->Username = $this->api->getConfig("tmail/phpmailer/username", null);
     $mail->Password = $this->api->getConfig("tmail/phpmailer/password", null);
     $mail->SMTPSecure = 'tls';
     $mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
     $mail->AddAddress($to);
     $mail->Subject = $subject;
     $mail->MsgHTML($body);
     $mail->AltBody = null;
     $mail->IsHTML(true);
     $bcc = $this->api->getConfig("tmail/phpmailer/bcc", null);
     if ($bcc) {
         $bcc_name = $this->api->getConfig("tmail/phpmailer/bcc_name", null);
         $mail->AddBCC($bcc, $bcc_name);
     }
     $internal_header_map = array("Content-Type" => "ContentType");
     $void_headers = array("MIME-Version");
     $fromAdded = false;
     foreach (explode("\n", $headers) as $h) {
         if (preg_match("/^(.*?):(.*)\$/", $h, $t)) {
             if (strtolower($t[1]) == "from" && $t[2]) {
                 $mail->SetFrom($t[2]);
                 $fromAdded = true;
                 continue;
             }
             if (isset($internal_header_map[$t[1]])) {
                 $key = $internal_header_map[$t[1]];
                 $mail->{$key} = $t[2];
                 continue;
             } else {
                 if (in_array($t[1], $void_headers)) {
                     continue;
                 }
             }
         }
         $mail->AddCustomHeader($h);
     }
     if (!$fromAdded) {
         $mail->SetFrom($this->api->getConfig("tmail/phpmailer/from"), $from ? "" : $this->api->getConfig("tmail/phpmailer/from_name"));
         $mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
     }
     $mail->Send();
 }
Example #7
0
function sendEmail($email,$subjectMail,$bodyMail,$email_back){

	$mail = new PHPMailer(true); 
	$mail->IsSMTP(); // telling the class to use SMTP
	try {
	  //$mail->Host       = SMTP_HOST; // SMTP server
	  $mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
	  $mail->SMTPAuth   = true;                  // enable SMTP authentication
	  $mail->Host       = SMTP_HOST; // sets the SMTP server
	  $mail->Port       = SMTP_PORT;                    // set the SMTP port for the GMAIL server
	  $mail->Username   = SMTP_USER; // SMTP account username
	  $mail->Password   = SMTP_PASSWORD;        // SMTP account password
	  $mail->AddAddress($email, '');     // SMTP account password
	  $mail->SetFrom(SMTP_EMAIL, SMTP_NAME);
	  $mail->AddReplyTo($email_back, SMTP_NAME);
	  $mail->Subject = $subjectMail;
	  $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automaticall//y
	  $mail->MsgHTML($bodyMail) ;
	  if(!$mail->Send()){
			$success='0';
			$msg="Error in sending mail";
	  }else{
			$success='1';
	  }
	} catch (phpmailerException $e) {
	  $msg=$e->errorMessage(); //Pretty error messages from PHPMailer
	} catch (Exception $e) {
	  $msg=$e->getMessage(); //Boring error messages from anything else!
	}
	//echo $msg;
}
Example #8
0
function smtpMailer($to, $from, $from_name, $subject, $body)
{
    $mail = new \PHPMailer();
    // Cree un nouvel objet PHPMailer
    $mail->IsSMTP();
    // active SMTP
    $mail->IsHTML(true);
    $mail->CharSet = "utf-8";
    $mail->SMTPDebug = 0;
    // debogage: 1 = Erreurs et messages, 2 = messages seulement
    $mail->SMTPAuth = true;
    // Authentification SMTP active
    $mail->SMTPSecure = 'ssl';
    // Gmail REQUIERT Le transfert securise
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = GMailUSER;
    $mail->Password = GMailPWD;
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);
    $mail->setLanguage('fr', '/optional/path/to/language/directory/');
    //debug($mail);
    if (!$mail->Send()) {
        $errorMail = 'Mail error: ' . $mail->ErrorInfo;
    }
}
Example #9
0
 public static function _email($options = array())
 {
     require_once 'PHPMailerAutoload.php';
     //require_once 'class.phpmailer.php';
     $options['fromEmail'] = !empty($options['fromEmail']) ? $options['fromEmail'] : SUPERADMIN_EMAIL;
     $options['fromName'] = !empty($options['fromName']) ? $options['fromName'] : DONOTREPLYNAME;
     try {
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->SMTPDebug = 0;
         // debugging: 1 = errors and messages, 2 = messages only
         $mail->SMTPAuth = true;
         $mail->Username = MAIL_USERNAME;
         $mail->Password = MAIL_PASSWORD;
         $mail->SMTPSecure = MAIL_TLS;
         $mail->Host = MAIL_SMTP;
         $mail->Port = MAIL_PORT;
         $mail->IsHTML(true);
         $mail->SetFrom($options['fromEmail']);
         $mail->Subject = $options['subject'];
         $mail->Body = $options['message'];
         $mail->AddAddress($options['toEmail']);
         if (!$mail->Send()) {
             $expError = $mail->ErrorInfo;
             $a = 'error';
         } else {
             //echo "Message has been sent";
             $a = 'true';
         }
     } catch (phpmailerException $e) {
         $expError = $e->errorMessage();
         $a = 'error';
     }
     return $a;
 }
Example #10
0
 /**
  *
  * Can be used to add various types of address
  *
  * @param string $type
  * @param $address
  * @param string $name
  * @throws \InvalidArgumentException
  * @return $this
  * @author Tim Perry
  */
 public function addAddress($type, $address, $name = '')
 {
     if (empty($address) || filter_var($address, FILTER_VALIDATE_EMAIL) === false) {
         $message = "Invalid address please provide a valid email address";
         throw new \InvalidArgumentException($message);
     }
     switch ($type) {
         default:
         case 'to':
             $this->mailer->AddAddress($address, $name);
             break;
         case 'from':
             $this->mailer->SetFrom($address, $name);
             break;
         case 'bcc':
             $this->mailer->AddBCC($address, $name);
             break;
         case 'cc':
             $this->mailer->AddCC($address, $name);
             break;
         case 'replyto':
             $this->mailer->AddReplyTo($address, $name);
             break;
     }
     return $this;
 }
Example #11
0
 function send($to, $subject, $body, $ph = array())
 {
     error_reporting(E_ALL);
     // replace ph in body
     if (0 < count($ph)) {
         foreach ($ph as $key => $value) {
             $subject = str_replace("{" . $key . "}", $value, $subject);
             $body = str_replace("{" . $key . "}", $value, $body);
         }
     }
     // file_put_contents(PATH_CACHE . "email.html", $body);
     $mail = new \PHPMailer();
     $mail->charSet = "UTF-8";
     $mail->IsSMTP();
     $mail->SMTPDebug = 0;
     $mail->SMTPAuth = true;
     if (MAIL_SECURE != '') {
         $mail->SMTPSecure = MAIL_SECURE;
     }
     $mail->Host = MAIL_HOST;
     $mail->Port = MAIL_PORT;
     $mail->Username = MAIL_USER;
     $mail->Password = MAIL_PASS;
     $mail->Subject = $subject;
     $mail->SetFrom(MAIL_USER);
     $mail->AddAddress($to);
     $mail->MsgHTML($body);
     if (!$mail->Send()) {
         echo $mail->ErrorInfo;
     }
 }
 /**
  * Send an email notification to a user
  * 
  * @static
  * @since 1.1.0
  * @param string $user_id User object_id
  * @param string $subject Email subject line
  * @param string $message Email body
  */
 public static function notify_user($user_id, $subject, $message, $short_text = null)
 {
     $error = new argent_error();
     if (!class_exists('PHPMailer')) {
         $error->add('1042', 'PHPMailer is not available', NULL, 'argent_notification');
     }
     if ($error->has_errors()) {
         return $error;
     }
     $mail = new PHPMailer();
     $mail->AddReplyTo(NOTIFICATION_FROM_MAIL, NOTIFICATION_FROM_NAME);
     $mail->SetFrom(NOTIFICATION_FROM_MAIL, NOTIFICATION_FROM_NAME);
     $user_data = argent_uauth::user_get_data($user_id);
     if (argent_error::check($user_data)) {
         return $user_data;
     }
     $mail->AddAddress($user_data['email'], $user_data['display_name']);
     $mail->Subject = $subject;
     $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
     // optional, comment out and test
     $merge_fields = array('user_name' => $user_data['display_name'], 'email' => $user_data['email'], 'body' => $message, 'subject' => $subject, 'intro' => $short_text);
     $message_body = self::merge_template(ABSOLUTE_PATH . 'argent/html_email_templates/basic.html', $merge_fields);
     if (argent_error::check($message_body)) {
         return $message_body;
     }
     $mail->MsgHTML($message_body);
     if (!$mail->Send()) {
         $error->add('1040', 'Error sending mail', $mail->ErrorInfo, 'argent_notification');
         return $error;
     } else {
         return 'Mail sent to ' . $user_data['email'];
     }
 }
function email_senden($email, $username, $password)
{
    $empfaenger = $email;
    $betreff = CONFIG_SITE_NAME . ': Willkommen';
    $nachricht = "Hallo " . $username . ",\n\nDu hast Dich erfolgreich auf " . CONFIG_SITE_DOMAIN . " registriert. Bitte logge Dich jetzt mit Deinen Benutzerdaten ein, um Deinen Account zu aktivieren. Und dann kann es auch schon losgehen ...\n\nDamit Du Dich anmelden kannst, findest Du hier noch einmal Deine Benutzerdaten:\n\nE-Mail: " . $email . "\nBenutzername: " . $username . "\nPasswort: " . $password . "\n\nWir wünschen Dir noch viel Spaß beim Managen!\n\nSportliche Grüße\n" . CONFIG_SITE_NAME . "\n" . CONFIG_SITE_DOMAIN . "\n\n------------------------------\n\nDu erhältst diese E-Mail, weil Du Dich auf " . CONFIG_SITE_DOMAIN . " mit dieser Adresse registriert hast. Du kannst Deinen Account jederzeit löschen, nachdem Du Dich eingeloggt hast, sodass Du anschließend keine E-Mails mehr von uns bekommst. Bei Missbrauch Deiner E-Mail-Adresse meldest Du Dich bitte per E-Mail unter " . CONFIG_SITE_EMAIL;
    if (CONFIG_EMAIL_PHP_MAILER) {
        require './phpmailer/PHPMailerAutoload.php';
        $mail = new PHPMailer();
        // create a new object
        $mail->CharSet = CONFIG_EMAIL_CHARSET;
        $mail->IsSMTP();
        $mail->SMTPAuth = CONFIG_EMAIL_AUTH;
        $mail->SMTPSecure = CONFIG_EMAIL_SECURE;
        $mail->Host = CONFIG_EMAIL_HOST;
        $mail->Port = CONFIG_EMAIL_PORT;
        $mail->Username = CONFIG_EMAIL_USER;
        $mail->Password = CONFIG_EMAIL_PASS;
        $mail->SetFrom(CONFIG_EMAIL_FROM, CONFIG_SITE_NAME);
        $mail->Subject = $betreff;
        $mail->Body = $nachricht;
        $mail->AddAddress($empfaenger);
        $mail->Send();
    } else {
        $header = "From: " . CONFIG_SITE_NAME . " <" . CONFIG_SITE_EMAIL . ">\r\nContent-type: text/plain; charset=utf-8";
        mail($empfaenger, $betreff, $nachricht, $header);
    }
}
function Send_Mail($to, $subject, $body)
{
    require 'class.phpmailer.php';
    $from = "*****@*****.**";
    $mail = new PHPMailer();
    $mail->IsSMTP(true);
    // use SMTP
    $mail->IsHTML(true);
    $mail->SMTPAuth = true;
    // enable SMTP authentication
    $mail->Host = "tls://smtp.gmail.com";
    // Amazon SES server, note "tls://" protocol
    $mail->Port = 465;
    // set the SMTP port
    $mail->Username = "******";
    // SMTP  username
    $mail->Password = "******";
    // SMTP password
    $mail->SetFrom($from, 'HELLO');
    $mail->AddReplyTo($from, 'Reply');
    //$mail->Body= "kiểm tra email bạn nhé";
    //$mail->AltBody = "Bạn sao vậy Tí";
    $mail->Subject = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    $mail->Send();
}
Example #15
0
function Send_Mail($to, $subject, $body)
{
    require 'class.phpmailer.php';
    $from = "*****@*****.**";
    $mail = new PHPMailer();
    $mail->IsSMTP(true);
    // SMTP
    $mail->SMTPAuth = true;
    // SMTP authentication
    $mail->Mailer = "smtp";
    $mail->Host = "tls://email-smtp.us-east.amazonaws.com";
    // Amazon SES
    $mail->Port = 465;
    // SMTP Port
    $mail->Username = "******";
    // SMTP  Username
    $mail->Password = "******";
    // SMTP Password
    $mail->SetFrom($from, 'From Name');
    $mail->AddReplyTo($from, '9lessons Labs');
    $mail->Subject = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
}
Example #16
0
        function smtpmailer($para, $de, $de_nome, $assunto, $corpo)
        {
            global $error;
            $mail = new PHPMailer();
            $mail->IsSMTP();
            // Ativar SMTP
            $mail->SMTPDebug = 0;
            // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
            $mail->SMTPAuth = true;
            // Autenticação ativada
            $mail->SMTPSecure = 'ssl';
            // SSL REQUERIDO pelo GMail
            $mail->Host = 'smtp.gmail.com';
            // SMTP utilizado
            $mail->Port = 465;
            // A porta 465 deverá estar aberta em seu servidor
            $mail->Username = GUSER;
            $mail->Password = GPWD;
            $mail->SetFrom($de, $de_nome);
            $mail->Subject = $assunto;
            $mail->Body = $corpo;
            $mail->AddAddress($para);
            if (!$mail->Send()) {
                $error = 'Mail error: ' . $mail->ErrorInfo;
                return false;
            } else {
                ?>
	  <script>
		alert("Cadastro realizado com sucesso acesse seu email e ative o usuário!");
		window.location = 'index.php';
	  </script>
		<?php 
                return true;
            }
        }
Example #17
0
 function smtpmailer($to, $from, $from_name, $subject, $body)
 {
     global $error;
     $mail = new PHPMailer();
     // tạo một đối tượng mới từ class PHPMailer
     $mail->IsSMTP();
     // bật chức năng SMTP
     $mail->SMTPDebug = 0;
     // kiểm tra lỗi : 1 là  hiển thị lỗi và thông báo cho ta biết, 2 = chỉ thông báo lỗi
     $mail->SMTPAuth = true;
     // bật chức năng đăng nhập vào SMTP này
     $mail->SMTPSecure = 'ssl';
     // sử dụng giao thức SSL vì gmail bắt buộc dùng cái này
     $mail->Host = 'smtp.gmail.com';
     $mail->Port = 465;
     $mail->Username = GUSER;
     $mail->Password = GPWD;
     $mail->SetFrom($from, $from_name);
     $mail->Subject = $subject;
     $mail->Body = $body;
     $mail->AddAddress($to);
     if (!$mail->Send()) {
         $error = 'Gửi mail bị lỗi: ' . $mail->ErrorInfo;
         return false;
     } else {
         $error = 'Thư của bạn đã được gửi đi ';
         return true;
     }
 }
Example #18
0
 /**
  * Send a email with the given message and title. Targets are in array form >   array("name" => "Target's name", "email" => "Target's email address")
  * @param $message
  * @param $title
  * @param array $target
  * @return bool
  * @throws Exception
  * @throws phpmailerException
  */
 public function sendMail($message, $title, $target = array())
 {
     if (!class_exists('PHPMailer')) {
         throw new Exception("Couldn't find PHPMailer class!");
     }
     $mail = new \PHPMailer();
     // create a new object
     $mail->IsSMTP();
     // enable SMTP
     if (ADVANCEDLOGINSCRIPT_DEBUG) {
         $mail->SMTPDebug = 1;
         // debugging: 1 = errors and messages, 2 = messages only
         $mail->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));
     } else {
         $mail->SMTPDebug = 0;
     }
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = 'tls';
     $mail->Host = ADVANCEDLOGINSCRIPT_EMAIL_HOST;
     $mail->Port = 587;
     $mail->IsHTML(true);
     $mail->Username = ADVANCEDLOGINSCRIPT_EMAIL_USERNAME;
     $mail->Password = ADVANCEDLOGINSCRIPT_EMAIL_PASSWORD;
     $mail->SetFrom(ADVANCEDLOGINSCRIPT_EMAIL_USERNAME);
     $mail->Subject = $title;
     $mail->Body = $message;
     $mail->Timeout = 10;
     // set the timeout (seconds)
     foreach ($target as $person) {
         $mail->addAddress($person['email'], $person['name']);
     }
     return $mail->Send();
 }
Example #19
0
function smtpmailer($para, $de, $de_nome, $assunto, $corpo)
{
    global $error;
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // Ativar SMTP
    $mail->SMTPDebug = 0;
    // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
    $mail->SMTPAuth = true;
    // Autenticação ativada
    $mail->SMTPSecure = 'tls';
    // SSL REQUERIDO pelo GMail
    $mail->Host = 'smtp.live.com';
    // SMTP utilizado
    $mail->Port = 587;
    // A porta 587 deverá estar aberta em seu servidor
    $mail->Username = GUSER;
    $mail->Password = GPWD;
    $mail->SetFrom($de, $de_nome);
    $mail->Subject = $assunto;
    $mail->Body = $corpo;
    $mail->AddAddress($para);
    if (!$mail->Send()) {
        $error = 'Mail error: ' . $mail->ErrorInfo;
        return false;
    } else {
        $error = 'Mensagem enviada!';
        return true;
    }
}
Example #20
0
function Send_Mail($to, $subject, $body)
{
    require './class.phpmailer.php';
    $from = "*****@*****.**";
    $mail = new PHPMailer();
    $mail->IsSMTP(true);
    // SMTP
    $mail->SMTPAuth = true;
    // SMTP authentication
    $mail->Mailer = "smtp";
    $mail->Host = "mail.privateemail.com";
    // Amazon SES server, note "tls://" protocol
    $mail->Port = 465;
    // set the SMTP port
    $mail->Username = "******";
    // SES SMTP  username
    $mail->Password = "******";
    // SES SMTP password
    $mail->SetFrom($from, 'Crypto Maniac');
    $mail->AddReplyTo($from, 'Crypto Maniac');
    $mail->Subject = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    if (!$mail->Send()) {
        return false;
    } else {
        return true;
    }
}
Example #21
0
function smtpmailer($to, $from, $from_name, $subject, $avatar, $user, $link)
{
    global $error;
    $mail = new PHPMailer();
    // create a new object
    $mail->IsSMTP();
    // enable SMTP
    $mail->SMTPDebug = 0;
    // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true;
    // authentication enabled
    $mail->SMTPSecure = 'ssl';
    // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = GUSER;
    $mail->Password = GPWD;
    $mail->IsHTML(true);
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->AddEmbeddedImage('background1.jpg', 'background1img');
    $name = explode($avatar, '.');
    $mail->AddEmbeddedImage('templates/avatars/' . $avatar, 'avatarimg');
    $mail->Body = "<div style='width:100%;background-color:rgb(77, 16, 1);height:500px;font-size:20px;color:#fff'>\n\t\t<font face='century Gothic,sans-serif'>\n\t\t<img src='cid:background1img' style='z-index:-2;text-align:center;margin-left:195px;width:300px;'>\n\t\t\n\t\t<div style='margin-left:0px;margin-top:30px;text-align:center;'><img src='cid:avatarimg' style='width:100px;height:100px;padding:1px;border:3px solid #ddd;margin-top:5px;margin-left:-5px;' /><div style='margin-top:5px;margin-left:-5px;'>Hello " . $user . "</div>\n\t\t\t<p style='text-align:justify;max-width:500px;margin-left:120px;'>\"Campus Connect\" is an initiative by a group of student enthusiasts, aiming to solve some of the issues faced by BITSians.\"BITS QUORA\" is one of the many projects covered under this initiative. </p>\n\t\t\n\t\t<div style='text-align:center'><br>\n\t\t<p style='text-align:center'><a href='http://BITSQ/register.php?token=" . $link . "&mail=" . $to . "' style='margin-top:18px;color:#fff;text-decoration:none;cursor:pointer;background:green;padding:6px;border:2 px solid darkgreen;border-radius:2px'>Click here to confirm your mail.</a></p> </div>\n\t\t</div>\n\t\t<div style='color:#fff;font-size:18px;position:absolute;bottom:0px;margin-left:100px;'>\n\t\tRegards<br>\n\t\tAkhil Reddy<br>\n\t\tH-Rep VK-BHAWAN<br>\n\t\t7728835792<br><br>\n\t\t</div>\t\t\n\t\t</div>\n\t\t</font></div>";
    $mail->AddAddress($to);
    if (!$mail->Send()) {
        $error = 'Mail error: ' . $mail->ErrorInfo;
        return false;
    } else {
        $error = 'Confirmation Mail sent to the the provided mail!';
        return true;
    }
}
 function send_emailMailer($recipient, $sender, $name, $subject, $message)
 {
     //require_once("PHPMailer/class.phpmailer.php");
     include "PHPMailer/class.phpmailer.php";
     include "PHPMailer/class.smtp.php";
     $CI =& get_instance();
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // telling the class to use SMTP
     $mail->SMTPAuth = true;
     // enable SMTP authentication
     $mail->Host = $CI->config->item('smtp_host');
     // sets the SMTP server
     $mail->Port = 25;
     // set the SMTP port for the GMAIL server
     $mail->Username = $CI->config->item('smtp_username');
     // SMTP account username
     $mail->Password = $CI->config->item('smtp_password');
     // SMTP account password
     $mail->SetFrom($sender, $name);
     $mail->AddReplyTo($sender, $name);
     $mail->Subject = $subject;
     $mail->AltBody = "Reset email";
     // optional, comment out and test
     $mail->MsgHTML($message);
     $mail->AddAddress($recipient, '');
     if (!$mail->Send()) {
         return array("error" => "Mailer Error: " . $mail->ErrorInfo);
     } else {
         return true;
     }
 }
Example #23
0
function smtpmailer($para, $de, $de_nome, $assunto, $corpo, $tipo)
{
    if ($tipo == 0) {
        include "./phpmailer/class.phpmailer.php";
    } else {
        include "../phpmailer/class.phpmailer.php";
    }
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->IsHTML(true);
    $mail->SMTPDebug = 1;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'ssl';
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465;
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->SetFrom($de, $de_nome);
    $mail->Subject = $assunto;
    $mail->Body = $corpo;
    $mail->AddAddress($para);
    if (!$mail->Send()) {
        $erro = 'Erro: ' . $mail->ErrorInfo;
        return $erro;
    } else {
        return 'Informações enviadas para o seu e-mail!';
    }
}
Example #24
0
function PHPMailer($xmlDoc, $name, $email, $subject, $message)
{
    require "class.phpmailer.php";
    $parentNode = $xmlDoc->createElement('status');
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // telling the class to use SMTP
    $mail->SMTPAuth = true;
    // SMTP authentication
    $mail->SMTPSecure = "tls";
    $mail->Host = "smtp.gmail.com";
    // SMTP server
    $mail->Port = 587;
    // SMTP Port
    $mail->Username = "******";
    // SMTP account username
    $mail->Password = "******";
    // SMTP account password
    $mail->SetFrom('*****@*****.**');
    // FROM
    $mail->AddAddress('*****@*****.**', 'Jared');
    // recipient email
    $mail->Subject = 'Contact Form Submission';
    // email subject
    $mail->Body = 'FROM: ' . $name . " " . $email . " Subject: " . $subject . " Message: " . $message;
    if (!$mail->Send()) {
        $statusNode = $xmlDoc->createElement('mail_status', 0);
        echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent.';
        $statusNode = $xmlDoc->createElement('mail_status', 1);
    }
    $parentNode->appendChild($statusNode);
    return $parent;
}
Example #25
0
function sendEmail($email, $pass)
{
    require "../modules/PHPMailer/PHPMailerAutoload.php";
    $mail = new PHPMailer(true);
    $mail->AddAddress($email[0]["email"]);
    $mail->SetFrom("*****@*****.**");
    $mail->Subject = "Reset Password";
    $mail->AddReplyTo("*****@*****.**", "ASUW Expewrimental College");
    $mail->SetFrom("*****@*****.**", "ASUW Experimetnal College");
    $mail->Body = "We've received a request to change your password.\n\t\t\tPlease visit this link to reset: \n\t\t\thttps://depts.washington.edu/asuwxpcl/users/forgot.php?reset=" . $pass . "&email=" . $email[0]["email"] . " \n\t\t\tIf you did not request this email, ignore it.";
    try {
        $mail->Send();
    } catch (Exception $e) {
        error("Email Failure", $mail->ErrorInfo);
    }
}
function Send_Mail($to, $subject, $body)
{
    require 'class.phpmailer.php';
    $from = "*****@*****.**";
    $mail = new PHPMailer();
    $mail->IsSMTP(true);
    // use SMTP
    $mail->IsHTML(true);
    $mail->SMTPAuth = true;
    // enable SMTP authentication
    $mail->Host = "tls://smtp.gmail.com";
    // Amazon SES server, note "tls://" protocol
    $mail->Port = 465;
    // set the SMTP port
    $mail->Username = "******";
    // SMTP  username
    $mail->Password = "******";
    // SMTP password
    $mail->SetFrom($from, 'Find Your Perfect Roommate');
    $mail->AddReplyTo($from, 'Reply to Find Your Perfect Roommate');
    $mail->Subject = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    $mail->Send();
}
Example #27
0
function Send_Mail($to, $subject, $body)
{
    require 'class.phpmailer.php';
    $from = "*****@*****.**";
    $mail = new PHPMailer();
    $mail->IsSMTP(true);
    // use SMTP
    $mail->IsHTML(true);
    $mail->SMTPAuth = true;
    // enable SMTP authentication
    $mail->Host = "smtp.mandrillapp.com";
    // Mandrillapp.com SES server, note "tls://" protocol
    $mail->Port = 587;
    // set the SMTP port
    $mail->Username = "******";
    // SMTP  username
    $mail->Password = "******";
    // SMTP password
    $mail->SetFrom($from, 'ISA Website');
    $mail->AddReplyTo($from, 'ISA Website');
    $mail->Subject = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    $mail->Send();
}
Example #28
0
 function smtpmailer($para, $from, $de_nome, $subject, $corpo)
 {
     global $error, $smtpUsuario, $smtpSenha;
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // Ativar SMTP
     $mail->SMTPDebug = 0;
     // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
     $mail->SMTPAuth = true;
     // Autenticação ativada
     $mail->SMTPSecure = 'tls';
     // SSL REQUERIDO pelo GMail
     $mail->Host = 'smtp.gmail.com';
     // SMTP utilizado
     $mail->Port = 587;
     // A porta 587 deverá estar aberta em seu servidor
     $mail->Username = $smtpUsuario;
     $mail->Password = $smtpSenha;
     $mail->SetFrom($from, $de_nome);
     $mail->Subject = $subject;
     $mail->Body = $corpo;
     $mail->AddAddress($para);
     if (!$mail->Send()) {
         $error = '<div class="sent">Mail error: ' . $mail->ErrorInfo . '</div>';
         return false;
     } else {
         $error = '<div class="sent">Enviado com sucesso!</div>';
         return true;
     }
 }
Example #29
0
function Send_Mail($to, $subject, $body)
{
    require 'class.phpmailer.php';
    $from = "*****@*****.**";
    $mail = new PHPMailer();
    $mail->IsSMTP(true);
    // SMTP
    $mail->SMTPAuth = true;
    // SMTP authentication
    $mail->Mailer = "smtp";
    $mail->Host = "tls://smtp.gmail.com";
    // Amazon SES server, note "tls://" protocol
    $mail->Port = 465;
    // set the SMTP port
    $mail->Username = "******";
    // SES SMTP  username
    $mail->Password = "******";
    // SES SMTP password
    $mail->SetFrom($from, 'ENQUIP');
    $mail->AddReplyTo($from, 'sushantjadhav2010');
    $mail->Subject = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    if (!$mail->Send()) {
        return false;
    } else {
        return true;
    }
}
Example #30
-1
 function send($to, $from, $from_name, $subject, $body)
 {
     global $error;
     $mail = new PHPMailer();
     // create a new object
     $mail->IsSMTP();
     // enable SMTP
     $mail->SMTPDebug = 0;
     // debugging: 1 = errors and messages, 2 = messages only
     $mail->SMTPAuth = true;
     // authentication enabled
     $mail->SMTPSecure = 'ssl';
     // secure transfer enabled REQUIRED for Gmail
     $mail->Host = 'smtp.gmail.com';
     $mail->Port = 465;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->SetFrom($from, $from_name);
     $mail->Subject = $subject;
     $mail->Body = $body;
     $mail->AddAddress($to);
     if (!$mail->Send()) {
         $error = 'Mail error: ' . $mail->ErrorInfo;
         //echo $error;
         //die;
         return false;
     } else {
         $error = 'Message sent!';
         //die;
         return true;
     }
 }