require_once dirname(__FILE__) . '/../../external/php/geekMail-1.0.php';
if (defined('HEURIST_MAIL_TO_INFO')) {
    $toEmailAddress = HEURIST_MAIL_TO_INFO;
}
if (!(isset($toEmailAddress) && $toEmailAddress) && defined('HEURIST_MAIL_TO_ADMIN')) {
    $toEmailAddress = HEURIST_MAIL_TO_ADMIN;
}
if ($_POST["rectype"] == RT_BUG_REPORT && defined('HEURIST_MAIL_TO_BUG')) {
    $toEmailAddress = HEURIST_MAIL_TO_BUG;
}
if (!(isset($toEmailAddress) && $toEmailAddress)) {
    print '({"error":"The owner of this instance of Heurist has not defined either the info nor system emails"})';
    exit;
}
//send an email
$geekMail = new geekMail();
$geekMail->setMailType('html');
$geekMail->to($toEmailAddress);
// This is set up to send email to a Heurist instance via an email account (from which the records are harvested)
// TODO: replace hard-cioded email address with address passed to request
// TODO: for bug reporting, change back to generic gmail account for Heurist once a workflow
// TODO: has been establsihed for automatically harvesting and notifying emails
// $geekMail->to('*****@*****.**');
// but during development it's best just to send it to the team so we actually SEE them ...
$ids = "";
if ($_POST["rectype"] == RT_BUG_REPORT) {
    if (defined('HEURIST_MAIL_TO_BUG')) {
        $toEmailAddress = HEURIST_MAIL_TO_BUG;
    }
    $bug_title = $_POST["type:" . DT_BUG_REPORT_NAME];
    $geekMail->from("*****@*****.**", "Bug reporter");
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $contents = curl_exec($ch);
 // close cURL resource, and free up system resources
 curl_close($ch);
 #$contents = file_get_contents('../vcard.vcf');
 // and save it to a temporary location (so that it gets a nice filename)
 $dir = '/tmp/' . md5(time());
 mkdir($dir);
 $tempFile = $dir . '/NeilCrosby.vcf';
 file_put_contents($tempFile, $contents);
 // send the email
 require 'geekMail-1.0.php';
 $geekMail = new geekMail();
 $geekMail->setMailType('text');
 $geekMail->from('*****@*****.**', 'Neil Crosby');
 $geekMail->to($email);
 $geekMail->subject("Neil Crosby's vCard");
 $geekMail->message("Thanks for downloading my vCard.\n\nIf you're using an iPhone, scroll down to the bottom of the attached card to add it to your address book.\n\nDon't forget you can always get an up to date copy from http://neilcrosby.com/vcard");
 $geekMail->attach($tempFile);
 if ($geekMail->send()) {
     unlink($tempFile);
     header("Location: http://neilcrosby.com/vcard/via-email/sent/");
 } else {
     $errors = $geekMail->getDebugger();
     print_r($errors);
 }
 unlink($tempFile);
 exit;
require_once dirname(__FILE__) . '/../../external/php/geekMail-1.0.php';
if (defined('HEURIST_MAIL_TO_INFO')) {
    $toEmailAddress = HEURIST_MAIL_TO_INFO;
}
if (!(isset($toEmailAddress) && $toEmailAddress) && defined('HEURIST_MAIL_TO_ADMIN')) {
    $toEmailAddress = HEURIST_MAIL_TO_ADMIN;
}
if ($_POST["rectype"] == RT_BUG_REPORT && defined('HEURIST_MAIL_TO_BUG')) {
    $toEmailAddress = HEURIST_MAIL_TO_BUG;
}
if (!(isset($toEmailAddress) && $toEmailAddress)) {
    print '({"error":"The owner of this instance of Heurist has not defined either the info nor system emails"})';
    exit;
}
//send an email
$geekMail = new geekMail();
$geekMail->setMailType('html');
$geekMail->to($toEmailAddress);
// This is set up to send email to a Heurist instance via an email account (from which the records are harvested)
// TODO: replace hard-cioded email address with address passed to request
// TODO: for bug reporting, change back to generic gmail account for Heurist once a workflow
// TODO: has been establsihed for automatically harvesting and notifying emails
// $geekMail->to('*****@*****.**');
// but during development it's best just to send it to the team so we actually SEE them ...
$ids = "";
if ($_POST["rectype"] == RT_BUG_REPORT) {
    if (defined('HEURIST_MAIL_TO_BUG')) {
        $toEmailAddress = HEURIST_MAIL_TO_BUG;
    }
    $bug_title = $_POST["type:" . DT_BUG_REPORT_NAME];
    $geekMail->from("*****@*****.**", "Bug reporter");