示例#1
0
/**
 * Retrieve a URL and send the contents as an HTML email
 * 
 * @param string $sTo
 * @param string $sFrom
 * @param string $sSubject
 * @param string $sUrl
 * @return boolean Succes / failure
 */
function mailURL($sTo, $sFrom, $sSubject, $sUrl)
{
    if ($sHtmlBody = file_get_contents($sUrl)) {
        $sHtmlBody = addAbsoluteResources($sHtmlBody, sprintf('http://%s/', $_SERVER['HTTP_HOST']));
        $sTextBody = HTML2Text($sHtmlBody);
        return htmlEmail($sTo, $sFrom, $sSubject, $sTextBody, '', $sFrom, $sHtmlBody);
    } else {
        Error("URL {$sUrl} could not be opened");
        return false;
    }
}
示例#2
0
 /**
  * Send a multi-part HTML email.
  * 
  * @return bool
  */
 public function sendHTML($to, $from, $subject, $htmlContent, $attachedFiles = false, $customheaders = false, $plainContent = false, $inlineImages = false)
 {
     return htmlEmail($to, $from, $subject, $htmlContent, $attachedFiles, $customheaders, $plainContent, $inlineImages);
 }
示例#3
0
 /**
  * Send the email.
  */
 public function send($messageID = null)
 {
     Requirements::clear();
     $this->parseVariables();
     if (empty($this->from)) {
         $this->from = Email::getAdminEmail();
     }
     $this->setBounceHandlerURL($this->bounceHandlerURL);
     $headers = $this->customHeaders;
     $headers['X-SilverStripeBounceURL'] = $this->bounceHandlerURL;
     if ($messageID) {
         $headers['X-SilverStripeMessageID'] = project() . '.' . $messageID;
     }
     if (project()) {
         $headers['X-SilverStripeSite'] = project();
     }
     $to = $this->to;
     $subject = $this->subject;
     if (self::$send_all_emails_to) {
         $subject .= " [addressed to {$to}";
         $to = self::$send_all_emails_to;
         if ($this->cc) {
             $subject .= ", cc to {$this->cc}";
         }
         if ($this->bcc) {
             $subject .= ", bcc to {$this->bcc}";
         }
         $subject .= ']';
         unset($headers['Cc']);
         unset($headers['Bcc']);
     } else {
         if ($this->cc) {
             $headers["Cc"] = $this->cc;
         }
         if ($this->bcc) {
             $headers["Bcc"] = $this->bcc;
         }
     }
     if (self::$cc_all_emails_to) {
         if (trim($headers['Cc'])) {
             $headers['Cc'] .= ', ';
         }
         $headers['Cc'] .= self::$cc_all_emails_to;
     }
     if (self::$bcc_all_emails_to) {
         if (trim($headers['Bcc'])) {
             $headers['Bcc'] .= ', ';
         }
         $headers['Bcc'] .= self::$bcc_all_emails_to;
     }
     $result = htmlEmail($to, $this->from, $subject, $this->body, $this->attachments, $this->plaintext_body, $headers);
     Requirements::restore();
     return $result;
 }