Add files
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
// display all errors while testing
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
?>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPMailer Exception class.
|
||||
* PHP Version 5.5.
|
||||
*
|
||||
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
*
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2017 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
/**
|
||||
* PHPMailer exception handler.
|
||||
*
|
||||
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
|
||||
*/
|
||||
class Exception extends \Exception
|
||||
{
|
||||
/**
|
||||
* Prettify error message output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function errorMessage()
|
||||
{
|
||||
return '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
// import PHPMailer
|
||||
set_include_path (__DIR__);
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require 'PHPMailer.php';
|
||||
require 'SMTP.php';
|
||||
require 'Exception.php';
|
||||
|
||||
// global var for debug logging
|
||||
$debugOutput = '';
|
||||
|
||||
function sendEmail($timeout, $hostname, $usePort, $useEncryption, $username, $password, $recipient, $replyTo, $body, $subject) {
|
||||
try {
|
||||
// instantiate PHPMailer instance (true = enable exceptions)
|
||||
$result = [];
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
// server settings
|
||||
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // enable verbose output
|
||||
$mail->Debugoutput = function($str){
|
||||
$GLOBALS['debugOutput'] .= "$str<br>";
|
||||
};
|
||||
$mail->Timeout = $timeout;
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $hostname;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $username;
|
||||
$mail->Password = $password;
|
||||
// encryption setting
|
||||
if ($useEncryption === 'ssl'){
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
} elseif ($useEncryption === 'starttls'){
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
}
|
||||
$mail->Port = $usePort;
|
||||
|
||||
// recipients
|
||||
$mail->setFrom($replyTo);
|
||||
$mail->addAddress($recipient);
|
||||
$mail->addReplyTo($replyTo);
|
||||
|
||||
// content
|
||||
$mail->Subject = $subject;
|
||||
//$mail->msgHTML($body);
|
||||
//$mail->isHtml(true);
|
||||
$mail->isHtml(false);
|
||||
$mail->Body = $body;
|
||||
|
||||
// send message
|
||||
if (!$mail->send()) {
|
||||
$result = [
|
||||
'result' => false,
|
||||
'message' => $mail->ErrorInfo,
|
||||
'debug' => $GLOBALS['debugOutput']
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
'result' => true,
|
||||
'debug' => $GLOBALS['debugOutput']
|
||||
];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = [
|
||||
'result' => false,
|
||||
'errorMessage' => $e->getMessage(),
|
||||
'debug' => $GLOBALS['debugOutput']
|
||||
];
|
||||
} finally {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user