Close but not quite cigar - challenged with sending email from form
1 posts by 1 authors in: Forums > CMS Builder
Last Post: May 30, 2018 (RSS)
By Toledoh - May 30, 2018
Hi Equinox.
I used to struggle with that mailing script, but now I use the mailing tempaltes in CMSB.
So replace all email part of your code with something like the following. Then, create a template in /cmsb/admin.php?menu=_email_templates called FORM-NAME or whatever. The placeholders can then be used wherever you want (as the sender of the email, in the subject line or body)
If you want to send multiple email, just duplicate and the function, change the template_id and create another email template. I normally have 2, one sending to the site admin, and one to the user filling in the form.
if (!$errorsAndAlerts) {
// Send Admin Alert via Email Template
$emailHeaders = emailTemplate_loadFromDB(array(
'template_id' => 'FORM-NAME',
'placeholders' => array(
'user.name' => $_REQUEST['fullname'],
'user.company' => $_REQUEST['company'],
'user.phone' => $_REQUEST['phone'],
'user.email' => $_REQUEST['edit'],
'user.comment' => $_REQUEST['message'],
)));
$mailErrors = sendMessage($emailHeaders);
//
$errorsAndAlerts = "Thanks! We've sent your email.";
$_REQUEST = array(); // clear form or any further redirect stuff...
}
Tim (toledoh.com.au)