From 71784e4f781697c8f0e88894858506f2552d5429 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 27 Feb 2015 11:07:52 -0500 Subject: [PATCH] Adding Confirmation Emails Forms Adding to Giveaway and Getaway form. using templates: giveawayConfEmail.tpl getawayConfEmail.tpl --- Toolkit/Contacts/ContactUs.php | 58 ++++++++++ Toolkit/Contacts/GolfGiveaway.php | 15 +++ .../Contacts/GreatBigGaylordGolfGetaway.php | 16 +++ Toolkit/Contacts/templates/emailOwner.tpl | 108 +++++++++--------- .../Contacts/templates/getawayConfEmail.tpl | 39 +++++++ .../Contacts/templates/giveawayConfEmail.tpl | 38 ++++++ 6 files changed, 220 insertions(+), 54 deletions(-) create mode 100755 Toolkit/Contacts/templates/getawayConfEmail.tpl create mode 100755 Toolkit/Contacts/templates/giveawayConfEmail.tpl diff --git a/Toolkit/Contacts/ContactUs.php b/Toolkit/Contacts/ContactUs.php index 4336cdc..04fd2a3 100755 --- a/Toolkit/Contacts/ContactUs.php +++ b/Toolkit/Contacts/ContactUs.php @@ -873,6 +873,61 @@ class Toolkit_Contacts_ContactUs } } +/** + * Emails the owner the submitted data from the submitted form + * + * Uses a flexy template to render a nice looking html email. + * Fills in the supplied data from the form and doesn't add the + * empty fields the user didn't fill in. + * + * @param string $mailFactory What type of mail factory should we use + * + * @return boolean result of the mailing + * @access protected + */ + protected function sendConfirmation( + $emailSubject, + $emailTemplate, + $mailFactory = 'mail' + ) { + + $template = new HTML_Template_Flexy($this->flexyOptions); + $page = new stdClass(); + // for comments textarea need to replace newlines with br + $this->formData['comments']['element'] + = nl2br($this->getSubmitValue('comments')); + + $userEmail = $this->getSubmitValue('email'); + $page->email_from = OWNER_EMAIL; + $page->subject = $emailSubject; + $page->fname = $this->getSubmitValue('fname'); + $page->lname = $this->getSubmitValue('lname'); + + $template->compile($emailTemplate); + $htmlMsg = $template->bufferedOutputObject($page); + + $msg = "{$page->subject}\n\n"; + $msg .= "From {$page->fname} {$page->lname}\n\n"; + + $mimeMail = new Mail_mime("\n"); + $mimeMail->setFrom("Gaylord Golf Mecca <".OWNER_EMAIL.">"); + $mimeMail->setSubject($emailSubject); + $mimeMail->setHTMLBody($htmlMsg); + $mimeMail->setTXTBody($msg); + + $mail =& Mail::factory($mailFactory); + $body = $mimeMail->get(); + $headers = $mimeMail->headers($setHeader); + + $res = $mail->send($this->email, $headers, $body); + if (PEAR::isError($res)) { + return Toolkit_Common::handleError($res); + } else { + return $res; + } + } + + /** * Display errors with the form to the user * @@ -1103,6 +1158,9 @@ class Toolkit_Contacts_ContactUs if ($this->process(array(&$this, 'processData'), $this->mergeFiles)) { $this->freeze(); $this->emailOwner(); + if (method_exists($this, 'confirmation')) { + $this->confirmation(); + } $output = $this->successMsg; } $this->sent = true; diff --git a/Toolkit/Contacts/GolfGiveaway.php b/Toolkit/Contacts/GolfGiveaway.php index 693e710..a08254e 100755 --- a/Toolkit/Contacts/GolfGiveaway.php +++ b/Toolkit/Contacts/GolfGiveaway.php @@ -470,4 +470,19 @@ class Toolkit_Contacts_GolfGiveaway } // }}} + /** + * confirmation + * + * Send out the Confirmation email with subject and using template + * + * @access public + * @return void + */ + public function confirmation() + { + $this->sendConfirmation( + 'Gaylord Golf Giveaway', // Email Subject + 'giveawayConfEmail.tpl' // Email Template File + ); + } } diff --git a/Toolkit/Contacts/GreatBigGaylordGolfGetaway.php b/Toolkit/Contacts/GreatBigGaylordGolfGetaway.php index ef7235e..c5d1084 100755 --- a/Toolkit/Contacts/GreatBigGaylordGolfGetaway.php +++ b/Toolkit/Contacts/GreatBigGaylordGolfGetaway.php @@ -339,5 +339,21 @@ class Toolkit_Contacts_GreatBigGaylordGolfGetaway $this->setupElements($e); } + + /** + * confirmation + * + * Send out the Confirmation email with subject and using template + * + * @access public + * @return void + */ + public function confirmation() + { + $this->sendConfirmation( + 'Confirmation: Gaylord. America’s Summer Golf Mecca', // Email Subject + 'getawayConfEmail.tpl' // Email Template File + ); + } // }}} } diff --git a/Toolkit/Contacts/templates/emailOwner.tpl b/Toolkit/Contacts/templates/emailOwner.tpl index e574342..470ae94 100755 --- a/Toolkit/Contacts/templates/emailOwner.tpl +++ b/Toolkit/Contacts/templates/emailOwner.tpl @@ -1,61 +1,61 @@ - - {title:h} + + {title:h} - -

- - {subject:h} - -

-

- - From {fname:h} {lname:h} - -

- - - - - - - - -
- - {foreach:formData,v} - - - {if:v[nowrap]} - - {else:} - - {end:} - - {end:} -
- - {v[label]:h} - - - {v[element]:h} - - {v[element]:h} -
-
- - - - -
- - To ensure the delivery of these e-mails to your inbox, please add {email_from:h} to your e-mail Address Book or Safe List. - -
-
- + +

+ + {subject:h} + +

+

+ + From {fname:h} {lname:h} + +

+ + + + + + + + +
+ + {foreach:formData,v} + + + {if:v[nowrap]} + + {else:} + + {end:} + + {end:} +
+ + {v[label]:h} + + + {v[element]:h} + + {v[element]:h} +
+
+ + + + +
+ + To ensure the delivery of these e-mails to your inbox, please add {email_from:h} to your e-mail Address Book or Safe List. + +
+
+ diff --git a/Toolkit/Contacts/templates/getawayConfEmail.tpl b/Toolkit/Contacts/templates/getawayConfEmail.tpl new file mode 100755 index 0000000..cb70da9 --- /dev/null +++ b/Toolkit/Contacts/templates/getawayConfEmail.tpl @@ -0,0 +1,39 @@ + + + + + {title:h} + + + +

+ + {subject:h} + +

+ + + + + + + +
+

Thank you for entering the Gaylord America's Summer Golf Mecca's \"Great Big Gaylord Golf Getaway!

+

If you would like additional information on Golf in the Gaylord Area please visit + www.gaylordgolfmecca.com

+
+ + + + +
+ + To ensure the delivery of these e-mails to your inbox, + please add {email_from:h} to your e-mail Address Book or Safe List. + +
+
+ + + diff --git a/Toolkit/Contacts/templates/giveawayConfEmail.tpl b/Toolkit/Contacts/templates/giveawayConfEmail.tpl new file mode 100755 index 0000000..a69999b --- /dev/null +++ b/Toolkit/Contacts/templates/giveawayConfEmail.tpl @@ -0,0 +1,38 @@ + + + + + {title:h} + + + +

+ + {subject:h} + +

+ + + + + + + +
+

Thank you for entering to win a FREE 4 Nights/4 Days (6 rounds) GOLF PACKAGE to the Gaylord Golf Mecca!

+

This is a confirmation of your entry in the Gaylord Golf Giveaway

+
+ + + + +
+ + To ensure the delivery of these e-mails to your inbox, + please add {email_from:h} to your e-mail Address Book or Safe List. + +
+
+ + + -- 2.17.1