Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hello,

I am using Couch's mail feature rather than write my own PHP script, however I have read (I may be wrong) that this use's PHP's mail() function.

My problem is that all mail sent from a contact form to a Googlemail address, whether it be @googlemail or Google Apps hosting a domains email address, it ends up in the Spam folder.

I have searched up on the internet and have found the general answer to getting around this is via adding headers to the PHP script.

[*]http://stackoverflow.com/questions/5935087/how-do-i-prevent-mails-sent-through-php-mail-from-going-to-spam
[*]http://stackoverflow.com/questions/12188334/php-mail-form-sending-to-gmail-spam
[*]http://stackoverflow.com/questions/18229279/sending-email-via-php-mail-function-goes-to-spam

Is it possible to do this with Couch, or edit Couch's mail script?

Thank you.
Hi,

The cms:send_mail tag indeed uses PHP mail function internally.

Could you please paste in the exact code you are using to send the mail?
I think I can see what the problem might be.

Thanks.
Hi,

The code below that I use is pretty much an unaltered version of the one from the tutorial, however I changed it to use placeholders rather than labels etc.

Code: Select all
<div class="small-10 small-offset-1 large-6 f">
            <cms:form action='' method='post' id='contact_form'>
              <fieldset>
                <legend>Drop Us A Message</legend>
                <div class="row">
                   <div class="small-12 large-6 f">
                        <div class="small-12 large-12 columns">
                          <cms:input type='text' name='name' id='name' required='1' placeholder="Name*"/>
                        <div class="clear"></div>
                        <cms:if k_error_name>
                           <p id='name_error' class='error' style="display:block">Insert a Name</p>
                        </cms:if>
                        </div>
                        <div class="small-12 large-12 columns">
                          <cms:input type='text' name='email' id='email' required='1' validator='email' placeholder="Email*" />
                        <div class="clear"></div>
                        <cms:if k_error_email>
                           <p id='email_error' class='error' style="display:block">Enter a valid email address</p>
                        </cms:if>
                        </div>
                        <div class="small-12 large-12 columns">
                          <cms:input type='text' name='subject' id='subject' required='1' placeholder="Subject*"/>
                        <div class="clear"></div>
                        <cms:if k_error_subject>
                           <p id='subject_error' class='error' style="display:block">Enter a message subject</p>
                        </cms:if>
                        </div>
                   </div>
                     <div class="small-12 large-6 f">
                          <div class="small-12 large-12 columns">
                            <cms:input type='textarea' name='message' id='message' required='1' placeholder="Message*"></cms:input>
                        <div class="clear"></div>
                        <cms:if k_error_message>
                           <p id='message_error' class='error' style="display:block">Enter a message</p>
                        </cms:if>
                         </div>
                     </div>
                     <cms:if k_success >   
                     <p id='mail_success' class='success' style="display:block">Thank you. We'll get back to you as soon as possible.</p>
                     
                     <cms:send_mail from=k_email_from to=k_email_to subject='Contact Form for X'>
                        <p>The following is an email sent by a visitor to you via the contact form.</p>
                        <cms:show k_success />
                     </cms:send_mail>
                  </cms:if>
                     <div class="small-12 large-12 columns f">
                     <input type='submit' id='send_message' class="button expand" value='Submit' />
                  </div>
                </div>
              </fieldset>
            </cms:form>
         </div>


Note that I use Foundation on the website so that is why there are small-12 and large-12 for example.

Thank you.
Thank you.
I was interested in specifically the following portion of the code -
<cms:send_mail from=k_email_from to=k_email_to subject='Contact Form for X'>
..
</cms:send_mail>

It is a common practice to set the 'from' parameter to the visitor's submitted email (this facilitates replying back to the address). This also is a common reason for the mail being treated as spam because the 'from' domain then does not match the mail's originating server (i.e. the server Couch is running on).

However, that does not seem to be the case in your code. In any case, please ensure that the email address set in config.php for 'k_email_from' belongs your server's domain.

Additionally, you can try using the code for 'send_mail' here -
viewtopic.php?p=11772#p11772
With this code, we can use some additional parameters with cms:send_mail. We'd be interested in setting the 'return_path' to an address that matches your server's domain.

The revised code could then become -
Code: Select all
<cms:set my_from_email='you@yoursitedomain.com' />
<cms:set my_to_email='you@googlemail.com' />

<cms:send_mail from=my_from_email return_path=my_from_email to=my_to_email reply_to=frm_email subject='Contact Form for X'>
    ..
</cms:send_mail>

Please make sure 'my_from_email' is set to an email belonging to your site's domain.

Do let us know if this helps.
Thanks.
Hi,

The email used in config.php for k_email_from is registered with Google Apps (Googlemail) and is the domain of the website Couch is being used on, so I'm not sure if this matters.

But anyhow, I will give send_mail a go and let you know how I get on.

Thank you.
Hi KK,

I am trying the contact form to work on a localhost, the form is submitting successfully however I couldn't received email. How do i gonna fix this?

I used the mailer@mywebsite.com as for FROM and myemailaddress@yahoo.com as for TO.

Thank you for your assistance.
Hi and welcome itdhenz :)

As far as I know, the mail() function does not work reliably on local machines (that is because it depends on sendmail being installed which is usually not the case).

So, I wouldn't worry much about this happening at this stage. I am sure it will work once you migrate to a proper online host.

Thanks
7 posts Page 1 of 1