diff --git a/application/controllers/Ajax.php b/application/controllers/Ajax.php
index caf16816..598d54a6 100644
--- a/application/controllers/Ajax.php
+++ b/application/controllers/Ajax.php
@@ -312,39 +312,48 @@ function contact() {
$email = $this->input->post('email');
$message = $this->input->post('message');
- $this->load->library('email');
-
- //FIXME: This has to go in a config file.
- //Futhermore, password must be loaded throught env
- //variables.
- //
- //We could even do it with the mandrillapp api that
- //we added for #34
- $config['protocol'] = "smtp";
- $config['smtp_host'] = "smtp.mandrillapp.com";
- $config['smtp_port'] = "587";
- $config['smtp_user'] = "marc@toolwatch.io";
- $config['smtp_pass'] = "pUOMLUusBKdoR604DpcOnQ";
- $config['charset'] = "utf-8";
- $config['mailtype'] = "html";
- $config['newline'] = "\r\n";
-
- $this->email->initialize($config);
-
- $this->email->from('contact@toolwatch.io', 'Toolwatch contact');
- $this->email->to('marc@toolwatch.io', 'Marc');
- $this->email->reply_to($email, $name);
-
- $this->email->subject('Contact Toolwatch from '.$name);
-
- $bodyMessage = 'Name : '.$name.'
';
- $bodyMessage .= 'Email : '.$email.'
';
- $bodyMessage .= 'Message :
';
- $bodyMessage .= $message;
-
- $this->email->message($bodyMessage);
-
- if ($this->email->send()) {
+ $this->load->library('mandrill');
+
+ $messageMandrill = array(
+ 'html' => $message,
+ 'subject' => $subject,
+ 'from_email' => $email,
+ 'from_name' => $name,
+ 'to' => array(
+ array(
+ 'email' => 'marc@toolwatch.io',
+ 'name' => 'Marc',
+ 'type' => 'to',
+ )
+ ),
+ 'headers' => array(
+ 'Reply-To' => $email,
+ ),
+ 'important' => false,
+ 'track_opens' => true,
+ 'track_clicks' => true,
+ 'tags' => array($tags),
+ 'google_analytics_campaign' => $tags,
+ 'google_analytics_domains' => array('toolwatch.io'),
+ 'metadata' => array(
+ 'website' => 'toolwatch.io',
+ )
+ );
+
+ $async = false;
+ $ip_pool = 'Main Pool';
+
+ $scheduleTime = time();
+
+ $send_at = date('Y-', $scheduleTime).date('m-', $scheduleTime)
+ .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)-1).':'
+ .(date('i', $scheduleTime)).date(':s', $scheduleTime);
+
+ $mandrillResponse = $this->mandrill->messages->send($messageMandrill, $async, $ip_pool, $send_at);
+ log_message('info', 'Mandrill email: ' . print_r($mandrillResponse, true));
+
+
+ if ($mandrillResponse[0]['status'] === 'sent') {
$result['success'] = true;
} else {
$result['success'] = false;
diff --git a/application/libraries/Auto_email.php b/application/libraries/Auto_email.php
index dd082709..e61fc1df 100644
--- a/application/libraries/Auto_email.php
+++ b/application/libraries/Auto_email.php
@@ -293,9 +293,12 @@ private function sendAtString($scheduleTime) {
//order to send emails right away when exploring
//computation in the future / past
$scheduleTime = $scheduleTime - $this->timeOffset;
- return date('Y-', $scheduleTime).date('m-', $scheduleTime)
+
+ $returnValue = date('Y-', $scheduleTime).date('m-', $scheduleTime)
.(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)-1).':'
.(date('i', $scheduleTime)).date(':s', $scheduleTime);
+
+ return $returnValue;
}
/**
diff --git a/application/views/footer.php b/application/views/footer.php
index f7fbe157..bf516ed5 100644
--- a/application/views/footer.php
+++ b/application/views/footer.php
@@ -2,9 +2,9 @@
agent->is_mobile()){ ?>