Esempio n. 1
0
 function SendMail($address, $title, $message, $fromname = 'NONE')
 {
     $mail = new PHPMailer\PHPMailer();
     $mail->IsSMTP();
     $mail->CharSet = C('MAIL_CHARSET');
     $mail->AddAddress($address);
     $mail->Body = $message;
     $mail->From = C('MAIL_ADDRESS');
     $mail->FromName = $fromname;
     $mail->Subject = $title;
     $mail->Host = C('MAIL_SMTP');
     $mail->Port = C('MAIl_PORT');
     $mail->SMTPAuth = C('MAIL_AUTH');
     $mail->Username = C('MAIL_LOGINNAME');
     $mail->Password = C('MAIL_PASSWORD');
     $mail->IsHTML(C('MAIL_HTML'));
     return $mail->Send();
 }
Esempio n. 2
0
 /**
  * Send the mail
  *
  * @param CCMail 		$mail	The mail object.
  * @return void
  *
  * @throws Mail\Exception
  */
 public function send(CCMail $mail)
 {
     // create new phpmailer instance
     $driver = new PHPMailer\PHPMailer();
     // set the charset
     $driver->CharSet = 'utf-8';
     // set the xmailer tag
     $driver->XMailer = "ClanCatsFramework 2.0 Mail / PHPMailer " . $driver->Version;
     // get the mail data as array
     $mail_data = $mail->export_data();
     // from address and name
     list($from_email, $from_name) = $mail_data['from'];
     $driver->From = $from_email;
     if (!is_null($from_name)) {
         $driver->FromName = $from_name;
     }
     // set the recipients
     foreach ($mail_data['to'] as $email => $name) {
         $driver->AddAddress($email, $name);
     }
     // set bcc
     foreach ($mail_data['bcc'] as $email => $name) {
         $driver->addBCC($email, $name);
     }
     // set cc
     foreach ($mail_data['cc'] as $email => $name) {
         $driver->addCC($email, $name);
     }
     // add attachments
     foreach ($mail_data['attachments'] as $path => $name) {
         $driver->addAttachment($path, $name);
     }
     // set the subject
     $driver->Subject = $mail_data['subject'];
     // set the message
     $driver->Body = $mail_data['message'];
     $driver->AltBody = $mail_data['plaintext'];
     $driver->IsHTML(!$mail_data['is_plaintext']);
     // setup the driver
     $this->setup_driver($driver);
     if (!$driver->Send()) {
         throw new Exception("Mail failure: " . $driver->ErrorInfo);
     }
 }
Esempio n. 3
0
 public function generate_reset_password_token($email, $auth_token)
 {
     $email = strtolower($email);
     if ($this->auth_token_verification_fails($auth_token)) {
         if ($this->Service->Config()->debug_mode_is_on()) {
             $this->Service->Config()->collect_debug_data('<br>Could not verify auth token');
             var_dump($this->Service->Config()->get_debug_data());
         }
         return false;
     }
     $token = $this->generate_hash($email . "#H4bb415");
     $this->Service->Prote()->DBI()->People()->ResetMap()->add($this->email2id($email), 1, $token);
     $mail = new \PHPMailer\PHPMailer();
     // Set PHPMailer to use the sendmail transport
     // $mail->isSendmail();
     // $mail->IsSMTP(); // telling the class to use SMTP
     // $mail->Host       = "mail.acharyahabba.in"; // SMTP server
     // $mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
     // 1 = errors and messages
     // 2 = messages only
     $mail->isSMTP();
     // Set mailer to use SMTP
     $mail->Host = 'smtp.mailgun.org';
     // Specify mailgun SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = '******';
     // SMTP username from https://mailgun.com/cp/domains
     $mail->Password = '******';
     // SMTP password from https://mailgun.com/cp/domains
     $mail->SMTPSecure = 'tls';
     // Enable encryption, 'ssl'
     // $mail->SMTPAuth   = true;                  // enable SMTP authentication
     // $mail->SMTPSecure = "tls";
     // $mail->Host       = "mail.acharyahabba.in"; // sets the SMTP server
     // $mail->Host       = "smtp.gmail.com";
     // $mail->Port       = 465;                    // set the SMTP port for the GMAIL server
     // $mail->Username   = "******"; // SMTP account username
     // $mail->Password   = "******";
     //Set who the message is to be sent from
     $mail->setFrom('*****@*****.**', 'Reset');
     //Set an alternative reply-to address
     $mail->addReplyTo('*****@*****.**', 'habba');
     //Set who the message is to be sent to
     $mail->addAddress($email);
     //Set the subject line
     $mail->Subject = 'Password Reset- #Habba15';
     //Read an HTML message body from an external file, convert referenced images to embedded,
     //convert HTML into a basic plain-text alternative body
     $mail->IsHTML(true);
     $reset_url = 'http://acharyahabba.in/password-reset-verify/' . $email . '/' . $token;
     $reset_link = '<a href="' . $reset_url . '">Click here</a><br><br>';
     $mail->Body = 'We have recieved a request to reset your password.  Please follow this link - ' . $reset_link . ' <br> OR copy paste this url in your browser - ' . $reset_url . '<br> Thank you. ';
     //send the message, check for errors
     if (!$mail->send()) {
         //echo "Mailer Error: " . $mail->ErrorInfo;
         return 0;
     } else {
         //echo "Message sent!";
         return 1;
     }
 }