08-25-2016, 11:05 AM
The more I thought about it the more I realized my previous patch was simply non-helpful. Who wants debug capabilities as part of a form which can potentially be turned on simply by posting a value?!
Here's an alternate patch which helps both with the SMTPDebug (now simply documented to go to helpers.php and set the PHP variable - keeping someone from having to trace the includes to the bitter end) as well as improving the CSS columns/classes in email_test.php:
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-25 14:59:55.767586500 +0200
***************
*** 17,22 ****
--- 17,30 ----
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+ /* DEVELOPER NOTE:
+ If you are having difficulty with your email configuration, go to
+ users/helpers/helpers.php (around line 114) and set $mail->SMTPDebug
+ to a non-zero value. This is a development-platform-ONLY setting - be
+ sure to set it back to zero (or leave it unset) on any live platform -
+ otherwise you would open significant security holes.
+ */
?>
<?php require_once 'init.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
***************
*** 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">
--- 35,40 ----
***************
*** 49,59 ****
<div class="row">
<div class="col-sm-12">
- <!-- Left Column -->
- <div class="class col-sm-4"></div>
-
<!-- Main Center Column -->
! <div class="class col-sm-3">
<!-- Content Goes Here. Class width can be adjusted -->
<h1>
Test your email settings.
--- 43,50 ----
<div class="row">
<div class="col-sm-12">
<!-- Main Center Column -->
! <div class="class col-xs-12 col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6">
<!-- Content Goes Here. Class width can be adjusted -->
<h1>
Test your email settings.
***************
*** 61,89 ****
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' />
</form>
<!-- End of main content section
</div>
-
- <div class="class col-sm-1"></div>
</div>
</div>
--- 52,86 ----
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($mail_result){
! echo '<div class="alert alert-success" role="alert">Mail sent successfully</div><br/>';
}else{
! echo '<div class="alert alert-danger" role="alert">Mail ERROR</div><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><br />
<input class='btn btn-primary' type='submit' value='Send A Test Email' class='submit' />
</form>
<!-- End of main content section
</div>
</div>
</div>
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-25 14:44:05.035763700 +0200
***************
*** 110,116 ****
$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
--- 110,119 ----
$mail = new PHPMailer;
! /*
! $mail->SMTPDebug = 3; // Enable verbose debug output
! $mail->Debugoutput = 'html'; // debug output displays well in html
! */
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $smtp_server; // Specify main and backup SMTP servers
Here's an alternate patch which helps both with the SMTPDebug (now simply documented to go to helpers.php and set the PHP variable - keeping someone from having to trace the includes to the bitter end) as well as improving the CSS columns/classes in email_test.php:
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-25 14:59:55.767586500 +0200
***************
*** 17,22 ****
--- 17,30 ----
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+ /* DEVELOPER NOTE:
+ If you are having difficulty with your email configuration, go to
+ users/helpers/helpers.php (around line 114) and set $mail->SMTPDebug
+ to a non-zero value. This is a development-platform-ONLY setting - be
+ sure to set it back to zero (or leave it unset) on any live platform -
+ otherwise you would open significant security holes.
+ */
?>
<?php require_once 'init.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
***************
*** 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">
--- 35,40 ----
***************
*** 49,59 ****
<div class="row">
<div class="col-sm-12">
- <!-- Left Column -->
- <div class="class col-sm-4"></div>
-
<!-- Main Center Column -->
! <div class="class col-sm-3">
<!-- Content Goes Here. Class width can be adjusted -->
<h1>
Test your email settings.
--- 43,50 ----
<div class="row">
<div class="col-sm-12">
<!-- Main Center Column -->
! <div class="class col-xs-12 col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6">
<!-- Content Goes Here. Class width can be adjusted -->
<h1>
Test your email settings.
***************
*** 61,89 ****
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' />
</form>
<!-- End of main content section
</div>
-
- <div class="class col-sm-1"></div>
</div>
</div>
--- 52,86 ----
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($mail_result){
! echo '<div class="alert alert-success" role="alert">Mail sent successfully</div><br/>';
}else{
! echo '<div class="alert alert-danger" role="alert">Mail ERROR</div><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><br />
<input class='btn btn-primary' type='submit' value='Send A Test Email' class='submit' />
</form>
<!-- End of main content section
</div>
</div>
</div>
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-25 14:44:05.035763700 +0200
***************
*** 110,116 ****
$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
--- 110,119 ----
$mail = new PHPMailer;
! /*
! $mail->SMTPDebug = 3; // Enable verbose debug output
! $mail->Debugoutput = 'html'; // debug output displays well in html
! */
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $smtp_server; // Specify main and backup SMTP servers