We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40777
    • 6 Posts
    Hello dudes and dudettes,

    Im running modx 2.2.4, formit 2.1.1. PHP 5.3, not sure about mysql but should be up to date

    Problem is as follows:
    I implemented Formit to just send a simple mail. Weirdly enough, i couldnt actually put a valid email in the "emailTo" or "emailFrom" fields. If i use an @ in the email, the snippet crashes. I assume its interpreting it as a property list thing, but i can't figure out why its usually no problem, but now suddenly a major one. I had this problem once before on a different project and after some googling i think i resorted to creating a hook that changed [at] or to @ before emailing.

    So after i've been trying to work out why its not working this time, i resorted to using an ajax method to process the mail and running it with runSnippet.

    Form looks like this:

    <form method="post" action="[[~[[*id]]]]">
    						<input type="hidden" value="" name="atest"/>
    							<input type="text" value="" placeholder="Din e-mail" id="email" name="email" class="rounded_s"/>
    							<input type="submit" value="Skicka" class="redbutton rounded_s floatright" />
    				</form>
    


    When i detect form.submit() with some jquery, and prevent default form submit, the following code ends up running in an ajax.php file:

    if(empty($_POST['atest'])){
    		if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
    			$modx->runSnippet('FormIt', array(
    				'hooks'=>'spam,email',
    				'emailTpl'=>'newsletterEmailTpl',
    				'emailTo'=>$modx->getOption('emailsender'),
    				'emailFrom'=>'[email protected]',
    				'emailFromName'=>'xxxxxxxx.se',
    				'emailSubject'=>'Nyhetsbrevsanmälan'));
    			echo 'Success';
    		}else{
    			echo 'faultyemail';
    		}
    	}
    


    Feels crazy that something that usually works ends up taking a couple of hours to work around.

    Any suggestions on what i might have missed, causing @ to screw up? This is what didnt work btw:

    [[!FormIt?
    &hooks=`spam,email`
    &emailTo=`[email protected]`
    &emailFrom=`[email protected]`
    &emailSubject=`blblbalbabla`
    &emailTpl=`newsletterEmailTpl`
    &emailFromName=`Site.com`
    ]]
    


    While below "worked" (although obviously didnt send emails anywhere). Note only difference is a dot instead of @


    [[!FormIt?
    &hooks=`spam,email`
    &emailTo=`someemail.somewhere.com`
    &emailFrom=`no-reply.site.com`
    &emailSubject=`blblbalbabla`
    &emailTpl=`newsletterEmailTpl`
    &emailFromName=`Site.com`
    ]]
    


    Thankful for any hint/response!
    /Kristian

    This question has been answered by krillso. See the first response.

      Web developer at http://kaigan.se
    • discuss.answer
      • 40777
      • 6 Posts
      Well i stumbled across the problem. It seems that if i have several forms on a page i need to set &submitVar parameter to unique values on all forms across the page. When each form had a unique name on its respective input="submit", i was able to load the form with a @ in the email to... Might wanna check this bug out or add it to the documentation somewhere.
        Web developer at http://kaigan.se