Skip to content

Instantly share code, notes, and snippets.

@howellcc
Last active October 8, 2015 20:04
Show Gist options
  • Save howellcc/cad546f6e1bab262f6f7 to your computer and use it in GitHub Desktop.
Save howellcc/cad546f6e1bab262f6f7 to your computer and use it in GitHub Desktop.
CFMail in cfscript
if(IsDefined("form.mailto") and isValid('email',form.mailTo)) {
mailSvc = new mail();
mailSvc.setTo(form.mailto)
.setFrom(form.mailFrom)
.setSubject(form.subject)
.setType("html");
/* add mailparams */
mailSvc.addParam(file=expandpath(form.attachment),type="text/plain",remove=false);
savecontent variable="mailBody"{
WriteOutput("<html><body><p>"
& "#rc.formBean.getValue('formName')# - Submission at #dateTimeFormat(now(),"medium")#"
& "<br><br>"
& "First Name: #rc.formSubmissionBean.getValue('firstName')#<br/>"
);
}
/* send mail using send(). Attribute values specified in an end action like "send" will not persist after the action is performed */
mailSvc.send(body=mailBody);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment