function execute(&$controller, &$request, &$user)
 {
     //DB_DataObject::debuglevel(3);
     $tmp_account = $request->getParameter('account');
     $tmp_member = DB_DataObject::factory('member_temporary');
     $tmp_member->get('account', $tmp_account);
     $key = $tmp_member->activate_key;
     $to = $tmp_member->email;
     $account = $tmp_member->account;
     $activate_url = SCRIPT_PATH . 'activate/' . rawurlencode($key);
     $request->setAttribute('activate_url', $activate_url);
     // create mail.
     $subject = msg('confirm mail subject');
     $message = sprintf(msg('confirm mail body'), $activate_url);
     $from = array('From' => EMAIL_FROM);
     MailUtils::send($to, $subject, $message, $from, array(), 'mail');
     return VIEW_NONE;
 }
Example #2
0
 /**
  * Provides an interface for sending a mail
  *
  * @param string $to The e-mail address of recipient.
  * @param string $subject The subject
  * @param string $message The message
  * @param array  $header Mail headers
  * @param array  $params Additional parameters
  * @param string $driver Driver to send mail.
  * @param string $locale Locale to specify the character code.
  * @return mixed Send a mail or if fails a PEAR Error
  * @access public
  */
 function send($to, $subject, $message, $header = array(), $params = array(), $driver = 'sendmail', $locale = 'ja')
 {
     $crlf = "\r\n";
     $subject = MailUtils::convertSubjectByLocale($subject, $locale);
     $body = MailUtils::convertBodyByLocale($message, $locale);
     //$htmlBody          = MailUtils::convertBodyByLocale($message, $locale, "html");
     $mimeParams = MailUtils::getMimeParametersByLocale($locale);
     $driverParams = MailUtils::getDriverParameters($driver);
     $header['Subject'] = $subject;
     $header['To'] = $to;
     $mime = new Mail_mime($crlf);
     //set area of text
     $mime->setTXTBody($body);
     //set area of html
     //$mime->setHTMLBody($htmlBody);
     //set template file
     foreach ($_FILES as $attach) {
         if (file_exists($attach['tmp_name'])) {
             $mime->addAttachment($attach['tmp_name'], 'application/octet-stream', mb_encode_mimeheader($attach['name']));
         }
     }
     //get mail body part
     $body = $mime->get($mimeParams);
     //get mail header part
     $header = $mime->headers($header);
     $mail =& Mail::factory($driver, $driverParams);
     if (PEAR::isError($mail)) {
         trigger_error('ERROR: ' . $mail->getMessage(), E_USER_WARNING);
         exit;
     }
     $result = $mail->send($to, $header, $body);
     if (PEAR::isError($result)) {
         trigger_error('ERROR: ' . $result->getMessage(), E_USER_WARNING);
         exit;
     }
 }