To Changing The Email Subject
From FacileWiki
(Redirected from To Changing The Email Subject.)
Changing the Email subject.
After creating a form you may want to change the email subject of the message. There are a variety of potential methods of doing this but in this page I will focus on editing the email subject per form.
Steps
- After creating your form click on the edit form button.
- With the setting tabs displayed, set "Email Notification" to No
- Click on the "submit pieces" tab
- In the "end submit" section of this tab click on the "custom" option button. This will display a text box to type in PHP code
- Enter the code below
global $mosConfig_mailfrom, $mosConfig_fromname, $my;
$this->execPieceByName('ff_InitLib');
// Send profile to Client
$from = ff_getSubmit('fldReplyEmail'); //fldReplyEmmail is a field i defined when building a form for the person submitting the form to
enter their email address in. I simply pull this form value.
$fromname = ff_getSubmit('FirstName').' '.ff_getSubmit('Surname'); // FirstName and Surname are two fields of my form that I simply pull and concatenate, BUT this
could be of course anything you want it to be.
$subject = ff_getSubmit('fldSubject'); // flSubject is a hidden field in my form which I have set its value to the subject I want to
appear as my email subject. I simply pull it.
$recipient = 'your@email.com'; // Here I hardcoded the email where I want the form to be submitted too.
// Create the Body format for use in e-mail. I pull the below bit of code directly from the facile
form processor php file,
// with the addition to ignore hidden fields when building the body of the email. I did this
because the Hidden fields
// in my form are control fields like fldSubject which I dont want to appear in the submitted form
data.
foreach ($this->maildata as $data) {
if ($data[_FF_DATA_TYPE] != 'Hidden Input') {
$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl();
}
}
$this->sendMail($from, $fromname, $recipient, $subject, $body); // This line acutally emails off the form.
Remembering to substitute your own variables as you see appropriate.