phpmailer passwort reset
This commit is contained in:
22
php/php-dog/classes/CNetcupMailer.php
Normal file
22
php/php-dog/classes/CNetcupMailer.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
class CNetcupMailer extends PHPMailer
|
||||
{
|
||||
public function __construct($debug = false)
|
||||
{
|
||||
parent::__construct($debug);
|
||||
// $this->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
||||
$this->SMTPDebug = SMTP::DEBUG_OFF; //no output
|
||||
$this->isSMTP(); //Send using SMTP
|
||||
$this->Host = 'mxe8bd.netcup.net'; //Set the SMTP server to send through
|
||||
$this->SMTPAuth = true; //Enable SMTP authentication
|
||||
$this->Username = 'dog@hope-fly.de'; //SMTP username
|
||||
$this->Password = 'DgQduKV6uBWXQcCqmAjL'; //SMTP password
|
||||
$this->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
|
||||
$this->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1,20 +1,4 @@
|
||||
<?php
|
||||
|
||||
class CNetcupMailer extends PHPMailer
|
||||
{
|
||||
public function __construct($debug = false)
|
||||
{
|
||||
parent::__construct($debug);
|
||||
$this->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
||||
$this->isSMTP(); //Send using SMTP
|
||||
$this->Host = 'mxe8bd.netcup.net'; //Set the SMTP server to send through
|
||||
$this->SMTPAuth = true; //Enable SMTP authentication
|
||||
$this->Username = 'dog@hope-fly.de'; //SMTP username
|
||||
$this->Password = 'DgQduKV6uBWXQcCqmAjL'; //SMTP password
|
||||
$this->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
|
||||
$this->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
||||
}
|
||||
}
|
||||
class CMsg
|
||||
{
|
||||
var $success;
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
<?php
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Headers: access");
|
||||
header("Access-Control-Allow-Methods: POST");
|
||||
@ -7,6 +11,12 @@ header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers
|
||||
|
||||
session_start();
|
||||
|
||||
//Load Composer's autoloader
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
require __DIR__.'/classes/CNetcupMailer.php';
|
||||
|
||||
|
||||
require __DIR__.'/classes/Database.php';
|
||||
require __DIR__.'/classes/lib.php';
|
||||
|
||||
@ -77,27 +87,45 @@ $headers .= 'Bcc: ' . 'dog@hope-fly.de' . "\r\n\r\n";
|
||||
|
||||
//var_dump($headers);
|
||||
|
||||
try
|
||||
{
|
||||
$ret = mail($toEmail, $subject, $msg, $headers);
|
||||
if($ret)
|
||||
|
||||
$mail = new CNetcupMailer();
|
||||
|
||||
|
||||
try {
|
||||
//Server settings
|
||||
|
||||
//Recipients
|
||||
$mail->setFrom($fromEmail);
|
||||
$mail->addAddress($toEmail); //Add a recipient
|
||||
$mail->addReplyTo($fromEmail);
|
||||
$mail->addCC($fromEmail);
|
||||
$mail->addBCC('dog@hope-fly.de');
|
||||
|
||||
//Attachments
|
||||
|
||||
//Content
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $msg;
|
||||
|
||||
if ($mail->send())
|
||||
{
|
||||
$result = new CMsg(1, 200, "Email send successfully.");
|
||||
$storeResult = storeEmail();
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = new CMsg(1, 500, "Sorry, there was an error sending your email your file.");
|
||||
$result = new CMsg(1, 500, "Sorry, there was an error sending your email.");
|
||||
}
|
||||
echo $result->jsonarray();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$result = new CMsg(0, 500, $e->getMessage() );
|
||||
$err = "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
$err .= "\r\n" . $e->getMessage();
|
||||
$result = new CMsg(0, 500, $err);
|
||||
echo $result->jsonarray();
|
||||
}
|
||||
|
||||
|
||||
function storeEmail()
|
||||
{
|
||||
global $qr_id, $conn, $msg, $fromEmail;
|
||||
|
||||
@ -16,4 +16,5 @@ $conn = $db_connection->dbConnection();
|
||||
$auth = new Auth($conn, $allHeaders);
|
||||
|
||||
echo $auth->isValid();
|
||||
//echo (__DIR__);
|
||||
?>
|
||||
@ -4,13 +4,13 @@ use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
//Load Composer's autoloader
|
||||
require __DIR__.'../../vendor/autoload.php';
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
//Load Composer's autoloader
|
||||
require __DIR__.'./classes/lib.php';
|
||||
require './classes/lib.php';
|
||||
|
||||
//Create an instance; passing `true` enables exceptions
|
||||
$mail = new CNetcupMailer(true);
|
||||
//$mail = new PHPMailer(true);
|
||||
|
||||
|
||||
try {
|
||||
@ -26,9 +26,11 @@ try {
|
||||
//Attachments
|
||||
|
||||
//Content
|
||||
$mail->Subject = 'jo subject jo XXXXX';
|
||||
$mail->Body = 'XXXX This is the txt message bodyThis is the txt message body This is the txt message bodyThis is the txt message body';
|
||||
$mail->Subject = 'aaaa jo subject jo XXXXX';
|
||||
$mail->Body = 'aaaaaa XXXX This is the txt message bodyThis is the txt message body This is the txt message bodyThis is the txt message body';
|
||||
|
||||
// $mail->send();
|
||||
// echo 'Message has been NOT sent';
|
||||
$mail->send();
|
||||
echo 'Message has been sent';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user