Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Hi, sorry but I have a problem with the email that is generated with the couch form (the user fills out the form and the email of the form filled out by the user arrives).

the email only arrives in code format (I attach screenshot) and I can't understand what I'm forgetting to do/set.
Can I ask you for help?

the site is not online at the moment, it is on a server but pointing is required to see it (ip / file di host).

Thanks
Best regards

Attachments

Hi,

Are you sure you have set the 'html' param to '1'? e.g. as follows -
Code: Select all
<cms:send_mail html='1' 
Hi, Thanks for the reply. Yes, I set this parameter but despite this the email that comes to me from the form is still in code format (you only see the code as per the screenshot sent yesterday). I can't understand where I'm wrong.
Thanks
Best regards

Attachments

Please PM me the full code you are using for the email (with embedded snippets if any used).
Thanks for sending me the requested code.
I tested and it is working just fine for me (i.e. I am getting the email in HTML format as expected).

So nothing wrong with the code per se.
Assuming you are not using an ancient version of Couch, the phpmailer addon should be a part of your installation.
I suggest you please try it instead of relying on the native PHP mail and see if this fixes the issue.

To do that, you only need to find the highlighted directive below in your couch/config.php file and change its value from 0 to 1
// 15.
// By default the inbuilt php function 'mail()' is used to deliver messages.
// On certain hosts this function might fail due to configuration problems.
// In such cases, set the following to '1' to use an alternative method (phpMailer) to send emails
define( 'K_USE_ALTERNATIVE_MTA', 0 );


Let me know how it goes.
Hi, Thank you very much!

I set the code in the config.php file to 1 but it doesn't format the email correctly and I can't understand why (you always see all the code).

the php version we are using on the server is 8.3. I also tried using different versions (like 8.0) but there's nothing to do.

What else could be wrong?
Thanks,
Best regards
Hi,
sorry, I'm writing after some time because this problem is unfortunately recurring with php versions 8.0 and above (8.0 to 8.4). the emails that Couch sends to report that a user has filled out the form arrive with the code and not with the correct formatting. if we move the php version of the space to 7.4 this problem does not occur. the problem is that now php 7.4 to 8.1 can be considered deprecated. we have tried to solve this problem in every way but there is no way. do you have a solution that you can provide us?
thank you very much
Best regards

Attachments

Hi,

Could you please let me know which version of Couch is being used for your site?
In case it is an older version please upgrade to the latest from GitHub.

Feel free to PM me your code if that does not help.
Hi again,

It seems there is indeed a bug with PHP 8.x that causes the problem you are experiencing
- https://github.com/PHPMailer/PHPMailer/pull/2188

To fix it, please try the following two steps-

1. As already mentioned before, if not already done so, please switch to PHPMailer.
To do that, find the highlighted directive below in your couch/config.php file and change its value from 0 to 1
// 15.
// By default the inbuilt php function 'mail()' is used to deliver messages.
// On certain hosts this function might fail due to configuration problems.
// In such cases, set the following to '1' to use an alternative method (phpMailer) to send emails
define( 'K_USE_ALTERNATIVE_MTA', 1 );

2. Just the first step above, however, is not sufficient.
We also need to make PHPMailer use SMTP as its method of sending emails.
To do that, do the following -

In your 'couch/addons/phpmailer' folder you'll find a file named 'config.example.php'.
Please rename it to 'config.php'

The default settings given in this file assume that you have an external SMTP server (e.g. GMail etc.) and you have the username/password for the account used to send emails.
For your case, we'll instead use the SMTP server that already exists on your web-server (localhost) which is what PHP uses by default and, using which, your emails have been going through fine so far.

To configure that, please make the settings in the file in question to match the follows -
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']   = '';      // Address of the SMTP server. If left empty, defaults to 'localhost'.
    $cfg['port']   = '';                 // Port of the SMTP server. If left empty, defaults to '25'.   
    $cfg['secure'] = '';                 // encryption to use on the SMTP connection. Valid options are '', 'ssl' or 'tls'.
    $cfg['authentication_required'] = '0';  // set this to '0' if your SMTP server does not require authentication
   
        // If 'authentication_required' above is set to '1', the following credentials will be required
        //$cfg['username'] = 'your_email@gmail.com';
        //$cfg['password'] = 'your_password';


    // 3. Debug. If set to '1', will log all debug output in 'log.txt' at site's root.
    $cfg['debug'] = '0';

The settings above will make PHPMailer use the localhost SMTP server with no authentication required.
This should rectify the PHP 8 problem with email formatting.

Please try it and let me know if this helps.
Hi,
sorry for the delay, thank you so much for answering me.
let's try to do these steps and I'll update you,
thanks so much
12 posts Page 1 of 2