2012-08-14 58 views

回答

1
<?php 

class MailerDaemon { 

/** 
* Set $isHTML to true in case the content to be send is in HTML 
* if no CC is required, set $cc to be NULL 
*/ 

public function sendMail($toEmail, $toName, $subject, $content, $isHTML, $cc) { 
    try { 
     $config = array(
      'ssl' => 'tls', 
      'port' => '587', 
      'auth' => 'login', 
      'username' => '<Replace with your Mail Sender Username>', 
      'password' => '<Replace with your Mail Sender Password>', 
     ); 
     $transport = new Zend_Mail_Transport_Smtp("<Replace with your SMTP Hostname>", $config); 
     Zend_Mail::setDefaultTransport($transport); 
     $mail = new Zend_Mail(); 
     if ($isHTML) { 
      $mail->setBodyHtml($content); 
     } else { 
      $mail->setBodyText($content); 
     } 
     $mail->setFrom("<Replace with your Mail Sender Username/Email ID>", "<Replace with your Mail Sender Full Name>"); 
     $mail->addTo($toEmail, $toName); 
     if($cc==NULL){$mail->addCc($cc);} 
     $mail->setSubject($subject); 
     $mail->send($transport); 
    } catch (Exception $exc) { 
     echo $exc->getTraceAsString(); 
     return false; 
    } 
    return true; 
} 

} 

?> 
  1. 下載並解壓Zend的圖書館 http://www.zend.com/en/community/downloads
  2. 複製「Zend的」文件夾到你的工作目錄,可以在提取的文件夾(希望圖書館目錄下)中找到。
  3. 將以下代碼粘貼到PHP文件中並根據指示進行必要的更改。
+0

我的答案只針對他的問題。在Joomla的情況下,我覺得我很無奈 – 2012-08-14 18:59:19