2011-07-26 2 views
2

PHPMailer를 사용하여 Joomla 프로젝트에서 전자 메일을 보내고 있습니다. to와 cc 두 주소로 전자 메일을 보내면 두 사람 모두 전자 메일을 받지만 전자 메일에서는 이름을 가진 사람 만 볼 수 있습니다. 그 사람이 '숨은 참조'로 보내 졌으므로 이메일에 표시되지 않은 것처럼 느껴집니다. 이 동작은 조금 이상합니다.Joomla에서 PHPMailer를 사용하여 CC가 포함 된 전자 메일을 보내고있는 중

여기에 도움이 될 것입니다. 기본 줌라 메일러를 사용하지 않는 이유는

class EmailService { 

    public function __construct($from_address = NULL, $from_name = NULL) { 
     $config = & JFactory::getConfig(); 
     $from_address = isset($from_address) ? $from_address : $config->getValue('config.mailfrom'); 
     $from_name = isset($from_name) ? $from_name : $config->getValue('config.fromname'); 
     $sender = array(
      $from_address, 
      $from_name 
     ); 

     $this->mailer = JFactory::getMailer (); 
     $this->mailer->setSender($sender); 
    } 

     public function sendMail($recipient, $subject, $body, $type = 'html', $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null) { 
     if (!isset($this->mailer)) { 
      throw new Exception("No mailer instance found!"); 
     } 

     $this->mailer->addRecipient($recipient); 
     $this->mailer->setSubject($subject); 
     $this->mailer->setBody($body); 

     if ($type == "html") { 
      $this->mailer->isHTML(true); 
     } 

     if (isset($cc)) { 
      $this->mailer->addCC($cc); 
     } 

     if (isset($bcc)) { 
      $this->mailer->addBCC($bcc); 
     } 

     if (isset($attachment)) { 
      $this->mailer->addAttachment($attachment); 
     } 

     if (is_array($replyto)) { 
      $numReplyTo = count($replyto); 
      for ($i = 0; $i < $numReplyTo; $i++) { 
       $this->mailer->addReplyTo(array($replyto[$i], $replytoname[$i])); 
      } 
     } elseif (isset($replyto)) { 
      $this->mailer->addReplyTo(array($replyto, $replytoname)); 
     } 


     return $send = & $this->mailer->Send(); 
    } 

[편집] 다음은 사용

$recipient = array ("[email protected]"); 
$cc = array ("[email protected]"); 
$emailType = 'html'; 
$emailBody = "Some HTML content"; 

$this->emailService->sendMail($recipient, "Some Subject", $emailBody, $emailType, $cc); 
+0

당신은 코드를 붙여 수 있습니까? 외관이 옳았는데 전화가 잘못되었을 수도 있습니다. – jdog

+0

안녕하세요 jdog 나는이 방법을 사용하는 코드를 포함하도록 위에서 편집했습니다. – Amar

+0

나는 틀린 아무것도 볼 수 없다, 어쩌면 Joomla에 phpmailer의 더 새로운 (또는 다른) 버전에서 베끼는 시험? 또는 phpmailer의 디버깅을 켜서 무슨 일이 일어나고 있는지 확인하십시오. 가장 좋은 방법은 디버거를 사용하는 것입니다. – jdog

답변

0

의 조각입니다 :

다음은 코드? 이 기능을 사용하는 경우

$mailer =& JFactory::getMailer(); 

Joomla documentation for JMail

+1

위의 코드가 보이면 그 코드가 내가 사용하고있는 코드인지 알 수 있습니다. – Amar

관련 문제