Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi there!

I'm breaking my head over this. I can't seem to get my contact form working. Anyone mind taking a peek? I've tried the debugging mode, and the log.txt file filed: Delivery Success, though no email came through.

Basically my code looks like this:

Code: Select all
<cms:form action='' method='post' id='contact_form'>
               <label for="name">Name</label>
               <cms:input type='text' name='name' id='name' required='1' />

               <cms:if k_error_name>
                  <p id='name_error' class='error' style="display:block">Insert a Name</p>
               </cms:if>

               <label for="email">Email Address</label>
               <cms:input type='text' name='email' id='email' required='1' validator='email' />

               <cms:if k_error_email>
               <p id='email_error' class='error' style="display:block">Enter a valid email address</p>
               </cms:if>

               <label for="message">Message</label>
               <cms:input type='textarea' name='message' id='message' required='1' rows="30" cols="30"></cms:input>

               <cms:if k_error_message>
                  <p id='message_error' class='error' style="display:block">Enter a message</p>
               </cms:if>

               <cms:if k_success >   
                  <p id='mail_success' class='success' style="display:block">Thank you. I'll get back to you as soon as possible.</p>
                  
                  <cms:send_mail from=k_email_from to=k_email_to subject='Feedback from your site'>
                     The following is an email sent by a visitor to your site:
                     <cms:show k_success />
                  </cms:send_mail>
               </cms:if>

               <input type='submit' id='send_message' class="button" value='Submit' />
            </cms:form>


What am I doing wrong?
Seems a good regular form. What is the issue - email sending not working? Can you try it without form?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: Seems a good regular form. What is the issue - email sending not working? Can you try it without form?


Yes, the email sending is not working. I've tried it without form, als not working. What am I missing? I've also tried different emailaddresses.
@365promises, following post should help you in debugging the issue -
https://www.couchcms.com/forum/viewtopic.php?p=418#p418

In case, the problem turns out that even the PHP code fails to send the mail, you can try using phpMailer as an alternative. For which, please see -
viewtopic.php?p=17061#p17061

Hope it helps.
KK wrote: @365promises, following post should help you in debugging the issue -
https://www.couchcms.com/forum/viewtopic.php?p=418#p418

In case, the problem turns out that even the PHP code fails to send the mail, you can try using phpMailer as an alternative. For which, please see -
viewtopic.php?p=17061#p17061

Hope it helps.


Hi, thanks.

I tried creating a plain php file:

Code: Select all
<?php
$to  = 'my@email.com';
$subject = 'Test';
$message = 'hello';
$headers = 'From: another@email.com';

$rs = mail($to, $subject, $message, $headers);
echo '<h3>Email sent: ' . $rs . '</h3>';
?>


The script printed out: Email sent: 1, and it worked, an email came through.

Next, I added the debug parameter:

Code: Select all
<cms:send_mail from=k_email_from to=k_email_to subject='Feedback from your site' debug='1'>
    The following is an email sent by a visitor to your site:
    <cms:show k_success />
</cms:send_mail>


I submitted the form and reviewed the log.txt, which contained all the right data:

Code: Select all
=======================[2016-08-11 13:03:56]=======================
From: my@email.com
To: another@email.com
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Subject: Feedback from your site
Message:

The following is an email sent by a visitor to your site:
name: Test1
email: sender@email.com
message: This is a test message            

Delivery Success


But no email..
The Couch tag internally uses the same PHP function that is working for you. So, it'd be strange if one works while the other doesn't.

Please make sure to use the *exact same* values for the 'from' and 'to' parameters of the cms:send_mail tag as those you used with the PHP function.

Instead of 'k_email_from' and 'k_email_to' variables, hard-code the same addresses that you used with the other method e.g. as follows -
<cms:send_mail from="another@email.com" to="my@email.com" ..

Pardon my stressing the point once again - please make sure to use exactly the same addresses as with PHP.

Let me know how it goes.
KK wrote: The Couch tag internally uses the same PHP function that is working for you. So, it'd be strange if one works while the other doesn't.

Please make sure to use the *exact same* values for the 'from' and 'to' parameters of the cms:send_mail tag as those you used with the PHP function.

Instead of 'k_email_from' and 'k_email_to' variables, hard-code the same addresses that you used with the other method e.g. as follows -
<cms:send_mail from="another@email.com" to="my@email.com" ..

Pardon my stressing the point once again - please make sure to use exactly the same addresses as with PHP.

Let me know how it goes.


100% percent sure I used the very same values, since I copied them. I was thinking, the form is in my snippets folder and is called footer.html. I use it in almost every page (<cms:embed 'footer.html' />). Might have anything to do with it?
No, I don't think snippet has anything to do with this issue.

The log shows that the tag is executing and the function is getting called so things are working as expected upto a point.

Anyway, just one last try -
please check if you have not set the following in couch/config to '1' -
define( 'K_USE_ALTERNATIVE_MTA', 0 );

If that is not the case, my final suggestion would be to use the phpMailer addon I mentioned in a previous post. Perhaps that would do the trick.
8 posts Page 1 of 1