私はJoomlaプロジェクトで電子メールを送信するためにPHPMailerを使用しています。 toとccの両方のアドレスで電子メールを送信すると、両方の人が電子メールを受信しますが、電子メールではその名前の人のみが表示されます。その人物が「bcc」であると送信されたため、メールには表示されていないように感じます。この動作は少し奇妙です。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();
}
[EDIT] 後は、使用デフォルトJoomlaのメーラーを使用していないのはなぜ
$recipient = array ("[email protected]");
$cc = array ("[email protected]");
$emailType = 'html';
$emailBody = "Some HTML content";
$this->emailService->sendMail($recipient, "Some Subject", $emailBody, $emailType, $cc);
あなたは、この機能を使用したコードを貼り付けることはできますか?見た目は正しいので、あなたの呼び出しは間違っていますか? – jdog
こんにちはjdog私はこのメソッドを使用するコードを上記に編集しました。 – Amar
私は何か間違っているとは思わない、おそらく新しい(または別の)バージョンのphpmailerをJoomlaにコピーしようとしていますか?または、phpmailerのデバッグをオンにして、何が起きているかを確認します。デバッガでこれを見るのが最も良い – jdog