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