by
daldred » Tue Feb 02, 2016 4:36 am
Ok, here are the two relevant files, after re-testing just now:
First, using a downloaded PHPMailer - this works and sends email which arrives safely:
- Code: Select all
<?php
require '../../php/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '*myemailaddress*'; // SMTP username
$mail->Password = '*mypassword*'; // SMTP password
$mail-> SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->addAddress('xxxxxx@gmail.com', 'Me'); // Add a recipient
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->From = 'myemailaddress';
$mail->FromName = 'BlogMail';
$mail->Subject = 'MySubject';
$mail->Body = 'And the message';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Second, here's the config.php from couch/addons/phpmailer, which does not send mail. (I've left the original settings in comments):
- Code: Select all
<?php
if ( !defined('K_COUCH_DIR') ) die(); // cannot be loaded directly
/*
1. Method used for sending emails.
Four valid options available:
'smtp' - Send messages using SMTP (e.g. GMail).
'mail' - Send messages using PHP's mail() function.
'sendmail' - Send messages using $Sendmail.
'qmail' - Send messages using qmail.
*/
$cfg['method'] = 'smtp';
/*
2. SMTP settings: required only if $cfg['method'] above is set to 'smtp'.
*/
$cfg['host'] = 'localhost'; //'smtp.gmail.com'; Address of the SMTP server. If left empty, defaults to 'localhost'.
$cfg['port'] = '465'; //'587'; Port of the SMTP server. If left empty, defaults to '25'.
$cfg['secure'] = 'ssl'; // encryption to use on the SMTP connection. Valid options are '', 'ssl' or 'tls'.
$cfg['authentication_required'] = '1'; // set this to '0' if your SMTP server does not require authentication
// If 'authentication_required' is set to '1' above, the following credentials will be required
$cfg['username'] = '*myemailaddress*';
$cfg['password'] = '*mypassword*';
And the tags in the template which should swend mail from Couch:
<cms:send_mail from=*myemailaddress*'
to='xxxxxx@gmail.com' subject='Feedback from your site'>
Anything here (between the opening and closing tags of send_mail)
will form the body of the email that will be sent.
</cms:send_mail>
From that I'm expecting an email with the "Anything here..." contents, but nothing arrives.
I've also checked that it's not ended up being treated as spam by gmail.
Am I missing something really obvious? In my final test I copied the SMTP email and password from the working file to the non-working one, just to eliminate any typos in that aspect, but still no joy.