7

Joomlaに基づいています!documentation @ http://docs.joomla.org/Sending_email_from_extensions、以下のコードでメールを送信しようとしています:

function sendmail($file,$mailto)
{  
    $mailer =& JFactory::getMailer();
    //var_dump($mailer); exit;
    $config =&JFactory::getConfig();
    $sender = array( 
        $config->getValue( 'config.mailfrom' ),
        $config->getValue( 'config.fromname' )
    );

    $mailer->setSender($sender);         

    $recipient = array($mailto);           
    $mailer->addRecipient($recipient);

    $body   = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
    $mailer->setSubject('Your subject string');
    $mailer->setBody($body);
    // Optional file attached

    $mailer->addAttachment(JPATH_BASE.DS.'CSV'.DS.$file);

    $send =&$mailer->Send();

    if ( $send !== true ) {
        echo 'Error sending email: ' . $send->message;
    } else {
        echo 'Mail sent';
    }
}

($fileはファイル zip のフル パスで$mailto、my gmail です。)

ただし、メールを送信すると、次のエラーが表示されます。

メール機能をインスタンス化できませんでした。
致命的なエラー: 行 142 の /var/www/html/dai/components/com_servicemanager/views/i0602/view.html.php の保護されたプロパティ JException::$message にアクセスできません

このエラーの原因は何ですか?

4

4 に答える 4

2

正気を保って、Joomlaのメーラー実装を使用しないでください。経験したように信頼性が低いだけでなく、さまざまな文字セットやHTMLコンテンツの処理が不十分です。PHPMailerを含めて使用するだけです。

于 2012-10-03T13:04:39.097 に答える
1

変化する

echo 'Error sending email: ' . $send->message;

echo 'Error sending email:'.$send->get('message');

その後、コードを再度実行します。表示されるエラーは、インスタンス化されていない理由を教えてくれるはずです。

于 2013-03-07T05:12:54.907 に答える
1

joomlaで添付ファイル付きのメールを送信

   $from="noreplay@gmail.com";//Please set Proper email id
   $fromname="noreplay";
   $to ='admin@gmail.com';
   // Set a you want send email to
   $subject = "Download";
   $message = "Thank you For Downloading";
   $attachment = JPATH_BASE.'/media/demo.pdf';
   // set a file path
   $res = JFactory::getMailer()->sendMail($from, $fromname, $to,$subject,     $message,$mode=1,$cc = null, $bcc = null, $attachment);
   if($res)
   {
        $errormsg = "Mail Successfully Send";
   }
   else
   {
     $errormsg ="Mail Not Send";
   }

受信トレイまたはスパム フォルダのメールを確認した後。
メール ID が送信元 ID に適切に設定されていないため、スパム フォルダにメールが送信されます。

于 2014-03-13T09:48:18.427 に答える
0

数年間の Joomla 開発の後、 RSJOOMLA のRSFORM PROを使用して、Web サイトの訪問者がフォームに記入した後にメールを送信することをお勧めします。内部メール サーバーを処理するよりも管理がはるかに簡単です。

于 2012-10-02T13:26:16.657 に答える