Problems, need help? Have a tip or advice? Post it here.
20 posts Page 2 of 2
Since Gmail *is* responding, the addon seems to working fine.
As to why the mail gets rejected by Google, that is something to be investigated.

Since, in a previous message, you have already ascertained that PHPMailer does get your mail across, the logical thing to do now would be to use the exact same settings with this addon too. The code internally for both the methods is the same so what worked for one should also work for the other too.

Please try doing that and let me know how it goes.
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.
I have made some amends to the original code.
Could you please download the new version ( 'phpmailer.zip' at viewtopic.php?p=22911#p22911) and try it out?

Do let me know if this changes anything.
Hi

I've done that - but unfortunately with no change to the results.
Could you PM me FTP+Couch creds for your site please?
Thanks for the creds.

I tested and the addon seems to be working just fine for me.
I made no changes whatsoever to the config. Just added my email address as the 'cc' parameter of cms:send_mail and received the email without a hitch.

Could you please check again?
KK has found the issues here:

1. Mailing from the cms:send_mail tag was not working because I had caching set on the site. If using a cms:send_mail tag on a site with caching set, the page also needs to contain a <cms:no_cache /> tag at the top of the page.

2. The 'system' email was not sending because the 'from' address in couch/config.php didn't match the smtp credentials. I'd been told this shouldn't have mattered (provided the actual smtp auth was done correctly), but apparently it does!

Thanks again to KK for his involvement and support on this.
Applied this addon to my hosting provider. WORKS! :mrgreen:
It didn't work first, so I had to dig for an hour here and there.
My provider uses localhost, smtp, 25 port, authentication, secure=' '.

Finally, I changed this setting and everything worked:
/couch/addons/phpmailer/PHPmailer/class.phpmailer.php -> changed SMTPAutoTLS from true to false.
/**
* Whether to enable TLS encryption automatically if a server supports it,
* even if `SMTPSecure` is not set to 'tls'.
* Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
* @var boolean
*/
public $SMTPAutoTLS = false;

Hope it helps someone too.


PS. PhpMailer supports attachments? @KK, does this seem as another todo?
PhpMailer supports attachments? @KK, does this seem as another todo?
Sure :)
KK wrote:
PhpMailer supports attachments? @KK, does this seem as another todo?
Sure :)


Up :)
Bounty posted viewtopic.php?f=2&t=10411&p=25584#p25584 :D
20 posts Page 2 of 2

Who is online

In total there are 5 users online :: 1 registered, 0 hidden and 4 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Exabot [Bot] and 4 guests