Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hi guys, I need help, i need to notify my admin email when somebody post a comment so he can login and approve it.

how can i do? please i need it desperately...

thanks heaps
Manu
Okay, here you go:

On the articles/comments page, find the text which get displayed when the message has been succesfully submitted by the user. Following the tutorial, that would be the "Thanks ,blabla, will be reviewing soon" message. Now add a simple <cms:send_mail> function to that text (IN the IF function) and there you go.

<cms:send_mail>:
http://www.couchcms.com/docs/tags-refer ... _mail.html
Sincerely,
Johan

Brightsites
Webdesign, webdevelopment, webapplications, hosting, advice and more.
Just adding to what Johan rightly pointed out -

The 'comments_form.html' snippet included in the documentation (http://www.couchcms.com/docs/code/blog.zip)
already makes use of the cms:send_mail tag on posting of a moderated comment.
An excerpt from the file -
Code: Select all
<cms:if k_process_comment_success>
   <cms:send_mail from=k_email_from to=k_email_to subject='Comment posted'>
      The following comment has been posted at your site:
      <cms:show k_success />
   </cms:send_mail>

   <div class="k_successmessage">
      <p>
         Thank you for the feed back! <br>
         Your comment awaits moderation and will be published as soon as reviewed by the Admin.
      </p>
   </div>
<cms:else />
   <div class="k_errormessage">
      <p>
         Could not post comment! <br>
         The following error occured while processing your comment:<br>
         <cms:show k_process_comment_error />
      </p>
   </div>
</cms:if>
thanks guys, you are always amazing :)
guys sorry but i have some issues, this code is already in my snippet :(
Let us make sure first if we can at all send emails.
Try putting the following snippet in any of your template (put real email addresses in the 'from' and 'to' parameters)
<cms:send_mail from='sender@whatever.com' to='receiver@whatever.com' subject='Test Email' >
Hello!
</cms:send_mail>

Accessing the template should result in the email being sent.
If you do not get the email, add the 'debug' parameter to the code -
<cms:send_mail from='sender@whatever.com' to='receiver@whatever.com' subject='Test Email' debug='1'>
Hello!
</cms:send_mail>

Access the template again. A file named 'log.txt' should get created in the root of your website.
(if not, there is a permission issue so please manually create a file named 'log.txt' in your site's root and give it read/write permission).
The 'log.txt' file should contain info that will help you troubleshoot the problem.

You can also try setting the following in your 'config.php' to '1'
Code: Select all
    // 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 to send emails
    define( 'K_USE_ALTERNATIVE_MTA', 0 );

This will use an alternative method to try and send the mail.

Do let me know if this helps.
I'm getting 'Delivery Failed' in log.txt.. I configured config.php too ... dont' know what going wrong.. :O
Code: Select all
<?php
$to = 'mark71411@gmail.com';
$subject = 'Test';
$headers = "From: Test<admin@site.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";

$message = "<html><body>";
$message .= "<h1>Hello, World!</h1>";
$message .= "</body></html>";

mail($to, $subject, $message, $headers);

echo "Mail sent" ;
?>

I used the above code and getting mail successfully.. but when I'm using the cms code.. not getting a mail .. below is the cms code

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>
The cms:send_mail tag internally uses the PHP mail function so if the PHP version works so should the Couch tag.

Could you please try using explicit values for the 'to' and 'from' email addresses (the same that you used for the PHP mail function) like what follows?
Code: Select all
<cms:send_mail from='admin@site.com' to='mark71411@gmail.com' 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>

Make sure to turn off (set to 0) the alternative mailing method in config.php
define( 'K_USE_ALTERNATIVE_MTA', 0 );

Do let me know how it goes.
Thanks.
It worked finally :) Thanks for your help KK..
I know I was coming up with some silly questions.. sorry for my poor knowledge with coding and all..Anyway making K_USE_ALTERNATIVE_MTA to '0' has worked ..
10 posts Page 1 of 1