The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Debugging email setup
#1
I was having difficulty figuring out what was wrong with my email configuration. Everything seemed fine, but I kept getting the (someone unhelpful) "Email ERROR" message whenever I tried to test my email setup.

I modified the email setup test to allow for setting a debug level and then modified the helpers.php so that it would respond to the presence of $_POST['SMTPDebug'] to turn on debugging.

NOTE: This should *not* be turned on in a development environment! It opens significant security holes. But if you are struggling with an email configuration problem it can be invaluable for you...

(The checkbox to turn on the exceptions looks kind of gross - I'm still trying to figure out how to style things nicely within this framework...)

Here's the patch file:

diff -bcr ../UserSpice41/users/email_test.php ./users/email_test.php
*** ../UserSpice41/users/email_test.php 2016-08-15 15:51:50.062520500 +0200
--- ./users/email_test.php 2016-08-23 18:35:35.767763900 +0200
***************
*** 27,46 ****
Redirect::to('account.php');
}
?>
- <?php
- //PHP Goes Here!
-
- $query = $db->query("SELECT * FROM email");
- $results = $query->first();
-
- if(!empty($_POST)){
- $to = $_POST['test_acct'];
- $subject = 'Testing Your Email Settings!';
- $body = 'This is the body of your test email';
- $mail_result=email($to,$subject,$body);
- }
-
- ?>
<div id="page-wrapper">

<div class="container-fluid">
--- 27,32 ----
***************
*** 61,79 ****
It's a good idea to test to make sure you can actually receive system emails before forcing your users to verify theirs. <br><br>
<?php
if (!empty($_POST)){
if($mail_result){
echo 'Mail sent successfully<br/>';
}else{
echo 'Mail ERROR<br/>';
}
-
}
-
?>

<form class="" name="test_email" action="email_test.php" method="post">
<label>Send test to (Ideally different than your from address):
<input required size='50' class='form-control' type='text' name='test_acct' value='' /></label>

<label> </label>
<input class='btn btn-primary' type='submit' value='Send A Test Email' class='submit' />
--- 47,85 ----
It's a good idea to test to make sure you can actually receive system emails before forcing your users to verify theirs. <br><br>
<?php
if (!empty($_POST)){
+ /* these appear to be unused
+ $query = $db->query("SELECT * FROM email");
+ $results = $query->first();
+ */
+
+ $to = $_POST['test_acct'];
+ $subject = 'Testing Your Email Settings!';
+ $body = 'This is the body of your test email';
+ $mail_result=email($to,$subject,$body);
+
+ if (isset($_POST['SMTPDebug']))
+ echo "<br />\n";
if($mail_result){
echo 'Mail sent successfully<br/>';
}else{
echo 'Mail ERROR<br/>';
}
}
?>

<form class="" name="test_email" action="email_test.php" method="post">
<label>Send test to (Ideally different than your from address):
<input required size='50' class='form-control' type='text' name='test_acct' value='' /></label>
+ <label><input class='form-control' type="checkbox" name="PHPMailerExceptions" />Report Exceptions</label>
+ <label>Debug Level:
+ <select class='form-control' name="SMTPDebug">
+ <option value=0 selected="selected">Debugging OFF</option>
+ <option value=1>Client</option>
+ <option value=2>Client + Server</option>
+ <option value=3>Client + Server + Connection</option>
+ <option value=4>All messages</option>
+ </select>
+ </label>

<label> </label>
<input class='btn btn-primary' type='submit' value='Send A Test Email' class='submit' />
diff -bcr ../UserSpice41/users/helpers/helpers.php ./users/helpers/helpers.php
*** ../UserSpice41/users/helpers/helpers.php 2016-08-15 15:51:52.583452900 +0200
--- ./users/helpers/helpers.php 2016-08-23 18:14:53.755615900 +0200
***************
*** 108,116 ****
$smtp_password=$results->email_pass;
$smtp_transport=$results->transport;

! $mail = new PHPMailer;

//$mail->SMTPDebug = 3; // Enable verbose debug output

$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $smtp_server; // Specify main and backup SMTP servers
--- 108,119 ----
$smtp_password=$results->email_pass;
$smtp_transport=$results->transport;

! $exceptions = (isset($_POST['PHPMailerExceptions']) ? $_POST['PHPMailerExceptions'] : false);
! $mail = new PHPMailer($exceptions);

//$mail->SMTPDebug = 3; // Enable verbose debug output
+ if (isset($_POST['SMTPDebug']))
+ $mail->SMTPDebug = $_POST['SMTPDebug'];

$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $smtp_server; // Specify main and backup SMTP servers
  Reply


Messages In This Thread
Debugging email setup - by plb - 08-23-2016, 02:52 PM
Debugging email setup - by mudmin - 08-24-2016, 01:16 AM
Debugging email setup - by plb - 08-24-2016, 10:01 AM
Debugging email setup - by mudmin - 08-24-2016, 12:50 PM
Debugging email setup - by plb - 08-25-2016, 11:05 AM
Debugging email setup - by plb - 08-25-2016, 11:15 AM
Debugging email setup - by mudmin - 08-25-2016, 06:52 PM
Debugging email setup - by mudmin - 08-29-2016, 03:01 PM
Debugging email setup - by plb - 08-29-2016, 08:39 PM
Debugging email setup - by mudmin - 09-01-2016, 11:40 PM
Debugging email setup - by mudmin - 09-10-2016, 01:35 PM
Debugging email setup - by brian - 09-12-2016, 10:04 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)