We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36786 ☆ A M B ☆
    • 209 Posts
    I'm currently on modx cloud and need to send emails via SMTP for the contact form. I want it to come from a gmail address. I'm using SMTP but I just can't seem to get it right. I always get redirected back to the contact form page with no displayed errors, no email sent and no submissions logged in FormSave. Here is the form I am using and my SMTP settings. If someone could let me know what I'm getting wrong I would really appreciate it.

    SMTP Settings:
    Mail Charset: UTF-8
    Mail Encoding: 8bit
    SMTP Authentication: Yes
    SMTP Helo Message: [blank]
    SMTP Hosts: smtp.gmail.com
    SMTP Keep-Alive: No
    SMTP Port: 465
    SMTP Connection Prefix: tls
    SMTP Single To: No
    SMTP Timeout: 10
    SMTP User: [full gmail address to send emails from]
    Use SMTPL: Yes

    Form
    [[!FormIt?
    					&hooks=`recaptcha,spam,FormSave,email,redirect`
    					&emailTpl=`contactEmailTpl`
    					&emailTo=`[email protected]`
    					&redirectTo=`82`
    					&fsFormTopic=`Contact`
    					&validate=`name:required,
    						email:email:required,
    						name:required,
    						comments:required:stripTags
    				]]
    				
    				[[!+fi.error_message:notempty=`<p>[[!+fi.error_message]]</p>`]]
    				<form action="[[~[[*id]]]]" class="contact-form" id="contactform" method="post">
    <input type="hidden" name="nospam:blank" value="" />
    					<p class="input-block">
    						<label for="name">Your Name: <span class="required">*</span><i>(required)</i><span class="required">[[!+fi.error.name]]</required></label>
    						
    						<input type="text" name="name" id="name" />
    					</p>
    
    					<p class="input-block">
    						<label for="email">E-mail:  <span class="required">*</span><i>(required)</i><span class="required">[[!+fi.error.email]]</span></label>
    						<input type="text" name="email" id="email" />
    					</p>
    
    					<p class="input-block">
    						<label for="web">Website:<span class="required">[[!+fi.error.web]]</span></label>
    						<input type="text" name="web" id="web" />
    					</p>
    
    					<p class="input-block">
    						<label for="message">Message:  <span class="required">*</span><i>(required)</i><span class="required">[[!+fi.error.comments]]</span></label>
    						<textarea name="comments" id="message"></textarea>	
    					</p>			
    					
    					<p class="input-block">		
    							[[!+formit.recaptcha_html]]
        						[[!+fi.error.recaptcha]]
    					</p>	
    						
    					<p class="row">
    						<button type="submit" class="button gray">Send</button>
    					</p>
    				</form>	

      Ben Morrison
      Hacking templates to pieces since 2003
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It looks like you're making the same mistake that I make almost every time when using the sample form from the rtfm! You need to have the closing ` after the last validate part:
      &validate=`name:required,
        email:email:required,
        comments:required:stripTags`

      As it says in the documentation, the most common reason for the form to not work is errors in the validation property.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36786 ☆ A M B ☆
        • 209 Posts
        Quote from: sottwell at Nov 26, 2012, 03:06 AM
        It looks like you're making the same mistake that I make almost every time when using the sample form from the rtfm! You need to have the closing ` after the last validate part:
        &validate=`name:required,
          email:email:required,
          comments:required:stripTags`

        As it says in the documentation, the most common reason for the form to not work is errors in the validation property.

        That did it, I will have to remember that in the future. Thanks!
          Ben Morrison
          Hacking templates to pieces since 2003
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          When I gave the "site in 90 minutes" presentation, I had that prominently marked in my notes!
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 36786 ☆ A M B ☆
            • 209 Posts
            Ok this is odd. After a few test submissions it stopped working, even though nothing at all was changed. I just get the following:

            An error occurred while trying to send the email. SMTP Error: Could not connect to SMTP host.

            Did google decide to not like me?
              Ben Morrison
              Hacking templates to pieces since 2003
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              When you set up the SMTP settings in the System Settings, what was the SMTP host? Try telnet in a terminal window to the same host and see what you get back.

              http://support.google.com/mail/bin/answer.py?hl=en&answer=78775
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 36786 ☆ A M B ☆
                • 209 Posts
                I'm just going to disable the SMTP and use the php mail function. Thanks for all the help!
                  Ben Morrison
                  Hacking templates to pieces since 2003
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  By the way, I don't use SMTP from the Cloud, and mail is sent just fine from a Cloud installation. I created a new Cloud for the MODXpo demo, and sent a test post from a contact form, and it went right through - I couldn't figure out how to access my Gmail from the computer I was using - at least not quickly, anyway, as I don't read Dutch, Mark Hamstra having kindly let me use his MacBook Air so I didn't have to haul my machine around - but it was there waiting for me when I got home.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 36786 ☆ A M B ☆
                    • 209 Posts
                    Yep works just fine. Thanks!
                      Ben Morrison
                      Hacking templates to pieces since 2003