Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
16 posts Page 1 of 2
Hi there,

I would like to know if it is possible to edit the email content that is sent to me when i customer of mine has used the contact form on my website.

If this is possible please could you direct me to the correct file to edit.

Kind Regards
Alex

Attachments

Hi Alex,

Couch, for now, only sends out email in 'plain text' format (as opposed to 'richtext' or 'HTML' format). This format, as its name suggests, is just plain text and offers no options for setting font size, colors etc. Those are available with the other type.

That said, @cheesypoof has made some changes to allow using the HTML format too. We have not included this in the core as we have plans to use PHPMailer or SwiftMailer in future versions that'll allow, in addition to richtext, sending attachments.

You can ask him and, I'm sure, he'll explain the required changes to the code to send HTML mails.
Hi,

Thank you for the reply.

That would be great, thank you.
The change @KK mentioned takes place in the send_mail function of tags.php. Please backup this file and then replace the aforementioned function with the following:
Code: Select all
function send_mail( $params, $node ){
    global $FUNCS;

    extract( $FUNCS->get_named_vars(
                array(
                      'from'=>'',
                      'to'=>'',
                      'cc'=>'',
                      'bcc'=>'',
                      'reply_to'=>'',
                      'return_path'=>'',
                      'charset'=>'',
                      'subject'=>'',
                      'debug'=>'0',
                      'logfile'=>'',
                      'html'=>'0'
                      ),
                $params)
           );

    $from = trim( $from );
    $to = trim( $to );
    $cc = trim( $cc );
    $bcc = trim( $bcc );
    $reply_to = trim( $reply_to );
    $return_path = trim( $return_path );
    $charset = trim( $charset );
    if( $charset=='' ) $charset=K_CHARSET;
    $debug = ( $debug==1 ) ? 1 : 0;
    $logfile = trim( $logfile );
    $html = ( $html==1 ) ? 1 : 0;

    foreach( $node->children as $child ){
        $msg .= $child->get_HTML();
    }

    $headers = array();
    if( $cc ) $headers['Cc']=$cc;
    if( $bcc ) $headers['Bcc']=$bcc;
    if( $reply_to ) $headers['Reply-To']=$reply_to;
    if( $return_path ) $headers['Return-Path']=$return_path;
    $headers['MIME-Version']='1.0';
    if( $html ){
        $headers['Content-Type']='text/html; charset='.$charset;
    }
    else{
        $headers['Content-Type']='text/plain; charset='.$charset;

        $msg = $FUNCS->unhtmlentities( $msg, K_CHARSET ); // resurrecting (decoding) the entities. Shouldn't be required in HTML mails.
        $msg = strip_tags($msg);
    }

    $rs = $FUNCS->send_mail( $from, $to, $subject, $msg, $headers );
    if( $debug ){
        $log = "From: $from\r\nTo: $to\r\n";
        foreach( $headers as $k=>$v ){
            $log .= $k .': '.$v."\r\n";
        }
        $log .= "Subject: $subject\r\nMessage: $msg\r\n\r\n";
        ( $rs ) ? $log .= "Delivery Success" : $log .= "Delivery Failed";
        $FUNCS->log( $log, $logfile );
    }
    return;
}
You also need to enable html in the send_mail tag like so:
Code: Select all
<cms:send_mail html='1'>
    ...
</cms:send_mail>
Hi cheesypoof,

Thank you for getting back to me, i have applied your edit.

You are a genius :)

How does one now edit the html of the content of the email?

Kind Regards
Alex
Your praise is perhaps unwarranted in this case, but I appreciate the sentiment :)

The content you place between the send_mail tag is now treated as HTML instead of plain text. It's up to you to decide how you utilize this change... You could simply edit the font size like your original post stated:
Code: Select all
<cms:send_mail from=k_email_from html='1' reply_to=frm_email subject=frm_subject to=k_email_to>
    <!doctype html>
    <html>
    <body>
        <p style="font-size:large;">
            The following is an email sent by a visitor to your site:<br/><br/>
            <strong>Name:</strong> <cms:show frm_name/><br/>
            <strong>Email Address:</strong> <cms:show frm_email/><br/>
            <strong>Subject:</strong> <cms:show frm_subject/><br/>
            <strong>Message:</strong><br/><br/>
            <cms:nl2br><cms:show frm_message/></cms:nl2br>
        </p>
    </body>
    </html>
</cms:send_mail>
You could also alternatively use an email template if you have additional requirements. The following are some popular options:
http://zurb.com/playground/responsive-email-templates
https://internations.github.io/antwort/index.html
Hi Cheesypoof,

That is perfect, so it would be best to use the embed tag and then i can create a full working email template.

Bloody amazing system, is there anything this CMS cannot do?

Thank you to both of you.

Alex
hello guys

i am facing delivery failure message at log,txt
i have modified config.php as well
but still not geting email notification
any one can help please?

thank You
@albalushi1, I'd suggest you please use the new PHPMailer addon -
viewtopic.php?f=5&t=10750

As discussed in the linked thread, of other things, the addon also provides detailed debugging information that should help you in troubleshooting the issue.

Hope it helps.
KK wrote: @albalushi1, I'd suggest you please use the new PHPMailer addon -
viewtopic.php?f=5&t=10750

As discussed in the linked thread, of other things, the addon also provides detailed debugging information that should help you in troubleshooting the issue.

Hope it helps.



thank you very much KK
the problem solved
appreciate it



can you please help with couch shopping cart
i need this demo source https://www.couchcms.com/demo/simple/
i download this demo, already but, it is different bit from live demo
16 posts Page 1 of 2

Who is online

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

Users browsing this forum: No registered users and 2 guests