Skip to content

Commit

Permalink
Merge pull request #4 from monkeyfeet/feature/contact
Browse files Browse the repository at this point in the history
Feature/contact
  • Loading branch information
Jeremy Cole authored Sep 15, 2017
2 parents a82e492 + 33fd51b commit 116ebcd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
18 changes: 9 additions & 9 deletions site/code/DataObjects/FormSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public function SendEmails(){

case 'ContactPage':
// --- ADMIN EMAIL ---
if( isset($this->Origin()->AdminEmail) ){
$to = $this->Origin()->AdminEmail;
if( isset($this->Origin()->ToEmail) ){
$to = $this->Origin()->ToEmail;
}else{
$to = $config->SendEmailsTo_Email;
}
$subject = $config->Title . ' Website contact form submission';
$data->Title = $data->Name . ' has made an enquiry.';
$data->Title = $data->Name . ' has made an enquiry through the contact form on divinelaziness.com';
$data->URL = Director::absoluteBaseURL();
$data->Data = ArrayList::create(array(
ArrayData::create(array(
Expand All @@ -119,12 +119,12 @@ public function SendEmails(){
$email->send();

// --- CUSTOMER EMAIL ---
$to = '"'.$data->Name.'" <'.$data->Email.'>';
$data->Title = 'Thanks for your message, we\'ll be in touch soon. The details you submitted are included below for your own records.';
$email = Email::create($from, $to, $subject, $body);
$email->setTemplate('Emails/FormSubmission');
$email->populateTemplate( ArrayData::create($data) );
$email->send();
// $to = '"'.$data->Name.'" <'.$data->Email.'>';
// $data->Title = 'Thanks for your message, we\'ll be in touch soon. The details you submitted are included below for your own records.';
// $email = Email::create($from, $to, $subject, $body);
// $email->setTemplate('Emails/FormSubmission');
// $email->populateTemplate( ArrayData::create($data) );
// $email->send();

break;

Expand Down
14 changes: 10 additions & 4 deletions site/code/Extensions/SiteConfigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@
class SiteConfigExtension extends DataExtension {

static $db = array(
'AdminToEmails' => 'Text',
'AdminFromEmail' => 'Text'
'SendEmailsTo_Email' => 'Text',
'SendEmailsFrom_Name' => 'Text',
'SendEmailsFrom_Email' => 'Text'
);

public function updateCMSFields(FieldList $fields){

$fields->addFieldToTab(
'Root.Emails',
TextAreaField::create('AdminToEmails','Admin "To" email address(es)')
TextAreaField::create('SendEmailsTo_Email','Admin "To" email address(es)')
->setDescription('Email addresses for deliver of global admin emails eg, contact form submissions etc.<br/>Can be comma-separated list.')
);

$fields->addFieldToTab(
'Root.Emails',
TextField::create('AdminFromEmail','Admin "From" email address')
TextField::create('SendEmailsFrom_Email','Admin "From" email address')
->setDescription('Email addresses for global admin emails to come "From"')
);
$fields->addFieldToTab(
'Root.Emails',
TextField::create('SendEmailsFrom_Name','Admin "From" email name')
->setDescription('Name for global admin emails to come "From"')
);

}

Expand Down
2 changes: 1 addition & 1 deletion site/templates/email/FormSubmission.ss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div style="border-top: 30px solid #FFFFFF; text-align: center;">
<a href="{$AbsoluteDomain}" style="border: 0; text-decoration: none;">
<img src="{$AbsoluteDomain}site/images/email-logo.gif" title="IMPAC logo" />
<img src="{$AbsoluteDomain}site/images/logo-75.png" title="Divine Laziness logo" />
</a>
</div>

Expand Down

0 comments on commit 116ebcd

Please sign in to comment.