Exemplo n.º 1
0
 private function mailCert($authKey)
 {
     try {
         $cert = $this->ca->getCert($authKey);
         if (isset($cert)) {
             $mm = new MailManager($this->person, Config::get_config('sys_from_address'), Config::get_config('system_name'), Config::get_config('sys_header_from_address'));
             $mm->setSubject($this->translateTag('l10n_mail_subject', 'download'));
             $mm->setBody($this->translateTag('l10n_mail_body', 'download'));
             $mm->addAttachment($cert, 'usercert.pem');
             if (!$mm->sendMail()) {
                 Framework::error_output($this->translateMessageTag('downl_err_sendmail'));
                 return false;
             }
         } else {
             return false;
         }
     } catch (ConfusaGenException $e) {
         Framework::error_output($this->translateMessageTag('downl_err_sendmail2') . " " . htmlentities($e->getMessage()));
         return false;
     }
     Framework::success_output($this->translateMessageTag('downl_suc_mail'));
 }
Exemplo n.º 2
0
 /**
  * Send a notification upon the issuance of a new X.509 certificate, as it is
  * required in section 3.2 of the MICS-profile.
  *
  * @param $orderNumber The unique identifier of the certificate - good to supply
  * that to the user
  * @param $timestamp Also include the time at which the certificate was signed
  * @param $ip And the IP-address of the contacting endpoint
  * @param $productName string the name of the certificate (eScience, personal,
  *                            code-signing) that we actually issued
  * @param $recipient person the person that is going to receive the
  *                          notification mail
  * @param $custom_content String|null the custom template to use when sending
  *					 the mail. If set, this will be used
  *					 instead of the default (from Config)
  */
 public static function sendMailNotification($orderNumber, $timestamp, $ip, $recipient, $distName, $custom_content = null)
 {
     /* if a notification e-mail is not a *template*, then what is? */
     $tpl = new Smarty();
     $nren = $recipient->getNREN();
     if (Config::get_config('cert_product') == PRD_ESCIENCE) {
         $productName = ConfusaConstants::$ESCIENCE_PRODUCT;
     } else {
         $productName = ConfusaConstants::$PERSONAL_PRODUCT;
     }
     $custom_template = Config::get_config('custom_mail_tpl') . $nren . '/custom.tpl';
     $tpl->compile_dir = ConfusaConstants::$SMARTY_TEMPLATES_C;
     $tpl->config_dir = Config::get_config('install_path') . 'lib/smarty/configs';
     $tpl->cache_dir = ConfusaConstants::$SMARTY_CACHE;
     $subscriber = $recipient->getSubscriber()->getOrgName();
     $support_mail = $recipient->getSubscriber()->getHelpEmail();
     $help_url = $recipient->getSubscriber()->getHelpURL();
     $dn = $distName;
     $download_url = Config::get_config('server_url') . '/download_certificate.php';
     if (isset($custom_content)) {
         $msg = $custom_content;
         $msg = str_ireplace('{$subscriber}', $subscriber, $msg);
         $msg = str_ireplace('{$subscriber_support_email}', $support_mail, $msg);
         $msg = str_ireplace('{$subscriber_support_url}', $help_url, $msg);
         $msg = str_ireplace('{$confusa_url}', Config::get_config('server_url'), $msg);
         $msg = str_ireplace('{$dn}', $dn, $msg);
         $msg = str_ireplace('{$download_url}', $download_url, $msg);
         $msg = str_ireplace('{$issue_date}', $timestamp, $msg);
         $msg = str_ireplace('{$ip_address}', $ip, $msg);
         $msg = str_ireplace('{$order_number}', $orderNumber, $msg);
         $msg = str_ireplace('{$product_name}', $productName, $msg);
         $msg = str_ireplace('{$nren}', $nren, $msg);
     } else {
         $tpl->assign('subscriber', $subscriber);
         $tpl->assign('subscriber_support_email', $support_mail);
         $tpl->assign('subscriber_support_url', $help_url);
         $tpl->assign('confusa_url', Config::get_config('server_url'));
         $tpl->assign('dn', $dn);
         $tpl->assign('download_url', $download_url);
         $tpl->assign('issue_date', $timestamp);
         $tpl->assign('ip_address', $ip);
         $tpl->assign('order_number', $orderNumber);
         $tpl->assign('nren', $nren);
         $tpl->assign('product_name', $productName);
         if (file_exists($custom_template)) {
             $msg = $tpl->fetch($custom_template);
         } else {
             $default_template = Config::get_config('install_path') . ConfusaConstants::$SMARTY_TEMPLATES . 'email/notification.tpl';
             $msg = $tpl->fetch($default_template);
         }
     }
     $subject = "Your new {$productName} certificate is ready.";
     /* send notification, test to see if it is *one* address, or multiple */
     $rce = $recipient->getRegCertEmails();
     if (empty($rce)) {
         /* fallback to standard mail address to be used in any case
          * (in case that session is not set) */
         $rce = array();
         $rce[] = $recipient->getEmail();
     }
     switch ($recipient->getNREN()->getEnableEmail()) {
         case '1':
             $mm = new MailManager($recipient, Config::get_config('sys_from_address'), Config::get_config('system_name'), Config::get_config('sys_header_from_address'), $rce[0]);
             $mm->setSubject($subject);
             $mm->setBody($msg);
             $mm->sendMail();
             break;
         case 'n':
             if (isset($rce) && count($rce) > 0) {
                 foreach ($rce as $email) {
                     $mm = new MailManager($recipient, Config::get_config('sys_from_address'), Config::get_config('system_name'), Config::get_config('sys_header_from_address'), $email);
                     $mm->setSubject($subject);
                     $mm->setBody($msg);
                     $mm->sendMail();
                 }
                 return;
             }
             /* if we don't have an email set, fall-through to standard,
              * i.e. send notification to default address. */
         /* if we don't have an email set, fall-through to standard,
          * i.e. send notification to default address. */
         default:
             $mm = new MailManager($recipient, Config::get_config('sys_from_address'), Config::get_config('system_name'), Config::get_config('sys_header_from_address'));
             $mm->setSubject($subject);
             $mm->setBody($msg);
             $mm->sendMail();
             break;
     }
 }