Last active
February 1, 2016 16:19
-
-
Save ThemeCatcher/9132553 to your computer and use it in GitHub Desktop.
SMTP debug file for Quform PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Once you've configured a recipient, "From" address, and the SMTP settings, | |
* upload this file to the "quform" folder on your web server and visit the | |
* page e.g. http://example.com/quform/smtp-check.php | |
*/ | |
error_reporting(-1); | |
@ini_set('display_errors', 'On'); | |
require_once dirname(__FILE__) . '/lib/PHPMailerAutoload.php'; | |
echo '<pre>'; | |
/* | |
* Enter the recipient email address | |
*/ | |
$recipient = 'me@example.com'; | |
/* | |
* Enter a "From" email address | |
*/ | |
$from = 'from@example.com'; | |
/* | |
* Enter the SMTP server settings | |
* | |
* host - SMTP server (e.g. smtp.example.com) | |
* port - SMTP port (e.g. 25) | |
* username - SMTP username | |
* password - SMTP password | |
* encryption - SMTP encryption (e.g. ssl or tls) | |
*/ | |
$config['smtp'] = array( | |
'host' => '', | |
'port' => 25, | |
'username' => '', | |
'password' => '', | |
'encryption' => '' | |
); | |
$mailer = new PHPMailer(true); | |
$mailer->isSMTP(); | |
$mailer->SMTPDebug = 2; | |
$mailer->Host = $config['smtp']['host']; | |
$mailer->Port = $config['smtp']['port']; | |
if ($config['smtp']['username']) { | |
$mailer->SMTPAuth = true; | |
} | |
$mailer->Username = $config['smtp']['username']; | |
$mailer->Password = $config['smtp']['password']; | |
$mailer->SMTPSecure = $config['smtp']['encryption']; | |
$mailer->Subject = 'Test Email'; | |
$mailer->Body = 'This is a test email.'; | |
$mailer->addAddress($recipient); | |
$mailer->From = $from; | |
if ($mailer->send()) { | |
echo 'Email sent!'; | |
} else { | |
echo 'Mailer error: ' . $mailer->ErrorInfo; | |
} | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment