Hi AMDbuilder,
Thank you very much for replying!
System info:
PHP Mailer: 2.0.4
MySQL: 5.0.77
PHP: 5.3.6
Do you need other server configuration details?
My form has been based on the emailUser snippet. See
http://modxrules.com/articles/send-a-confirmation-email-with-formit
Form:
<p>[[!FormIt? &hooks=`spam,email,emailUser,redirect` &emailTo=`
[email protected]` &emailSubject=`Bestelling bij visieinpraktijk.nu` &emailFromName=`[[+name]]` &emailTpl=`ContactTpl` &redirectTo=`7` &store=`1` ]]</p>
<div class="error">[[+fi.error.error_message]]</div>
<form class="form" action="[[~[[*id]]]]" method="post"><input type="hidden" name="nospam:blank" value="" />
<h3>bestelformulier</h3>
<p>Ja, ik wil graag het boek Werkgeversstrategie bestellen.</p>
<div class="textfield"><label for="name">Naam: </label> <span class="error">[[+fi.error.name]]</span><input id="name" style="width: 100%;" type="text" name="name:required" value="[[+fi.name]]" /></div>
<div class="textfield"><label for="company">Bedrijf: </label> <input id="company" style="width: 100%;" type="text" name="company" value="[[+fi.company]]" /></div>
<div class="textfield"><label for="address">Adres: </label> <span class="error">[[+fi.error.address]]</span><input id="address" style="width: 100%;" type="text" name="address:required" value="[[+fi.address]]" /></div>
<div class="textfield"><label for="zipcode">Postcode: </label> <span class="error">[[+fi.error.zipcode]]</span><input id="zipcode" style="width: 100%;" type="text" name="zipcode:required" value="[[+fi.zipcode]]" /></div>
<div class="textfield"><label for="city">Plaats: </label> <span class="error">[[+fi.error.city]]</span><input id="city" style="width: 100%;" type="text" name="city:required" value="[[+fi.city]]" /></div>
<div class="textfield"><label for="phone">Telefoon: </label> <span class="error">[[+fi.error.phone]]</span><input id="phone" style="width: 100%;" type="text" name="phone:required" value="[[+fi.phone]]" /></div>
<div class="textfield"><label for="email">E-mail: </label> <span class="error">[[+fi.error.email]]</span><input id="email" style="width: 100%;" type="text" name="email:email:required" value="[[+fi.email]]" /></div>
<div class="textfield"><label for="message">Ruimte voor opmerkingen: </label>
<textarea id="message" style="width: 100%;" name="message" rows="2">[[+fi.message]]</textarea></div>
<div id=""><input type="submit" name="Submit" value="Bestelling versturen" /></div>
</form>
emailUser snippet:
<?php
//configuration
$mailFrom = $modx->getOption('emailsender'); //OR USE YOUR OWN;
$mailFromName = $modx->getOption('site_name'); //OR USE YOUR OWN;
$mailSender = $modx->getOption('site_name'); //OR USE YOUR OWN;
$mailSubject = 'Uw bestelling bij visieinpraktijk.nu';
$mailReplyTo = $mailFrom;
//get fields values so they can be replaced in the email chunk
$confirmationFields['name'] = $scriptProperties['fields']['name'];
$confirmationFields['company'] = $scriptProperties['fields']['company'];
$confirmationFields['address'] = $scriptProperties['fields']['address'];
$confirmationFields['zipcode'] = $scriptProperties['fields']['zipcode'];
$confirmationFields['city'] = $scriptProperties['fields']['city'];
$confirmationFields['phone'] = $scriptProperties['fields']['phone'];
$confirmationFields['email'] = $scriptProperties['fields']['email'];
$confirmationFields['message'] = $scriptProperties['fields']['message'];
//get user's email
$mailTo= $scriptProperties['fields']['email'];
$message = $modx->getChunk('ConfirmationTpl', $confirmationFields);
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,$mailFrom);
$modx->mail->set(modMail::MAIL_FROM_NAME,$mailFromName);
$modx->mail->set(modMail::MAIL_SENDER,$mailSender);
$modx->mail->set(modMail::MAIL_SUBJECT,$mailSubject);
$modx->mail->address('to',$mailTo);
$modx->mail->address('reply-to',$mailReplyTo);
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
return false;
}
$modx->mail->reset();
return true;
I also created two chunks, ConfirmationTpl and ContactTpl, but like I said in my previous post, the e-mails work just fine. Only the redirect to the Thank you page doesn't work.
If I create a new user, I don't get a message in the error log.
Hope you can help me out.
Thanks again!