We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21772
    • 69 Posts
    こんにちは Noriです。

    久しぶりのMODxと格闘中です、0.9.5で運用していたサイトを
    0.9.6にバージョンアップし、OSもかなり古かったのでOSから
    全てを入れ替えました。

    現在の構成は
    OS Fedora7、PHP 5.2.2、eAccelerator v0.9.5、MySQL 5.0.37

    Modx自体は、UTF-8の環境で問題なく動作しているのですが、
    eForm 1.4.4でのエラーが気になって投稿しました。

    エラー内容は
    ≪ MODx Parse Error ≫
    MODx encountered the following error while attempting to parse the requested resource:
    ≪ PHP Parse Error ≫

    PHP error debug
    Error: mb_send_mail() [function.mb-send-mail]: Unsupported charset ""UTF-8"" - will be regarded as ascii
    Error type/ Nr.: Warning - 2
    File: /var/www/html/modx/manager/includes/controls/class.phpmailer.php
    Line: 438
    Line 438 source: $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);

    class.phpmailer.phpの、438行目を下のように変更
    //            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
                  $rt = @mb_send_mail($to, $this->Subject, $body);
    

    一応 eformからのメール送信は出来ていますが、PHPが良く分かって
    いないので、この変更であっているのでしょうか?。

    ググってみると、PHP 5からmail関係で、色々問題があるようなのですが、
    ドンピシャの症状がないので、質問致します。
      • 33488
      • 429 Posts
      UTF-8アンサポートって出てますね
      んーー、mb_languageかmb_internal_encodingが正しくなっていて出るようでしたら、PHP5関連の仕様の違いなのかも・・・
      試しにmb_sned_mailの前に上記2つの関数を呼び出してはどうでしょう?

      UTF-8メールでなくてもよければ、 http://modxcms.com/forums/index.php/topic,11941.0.html のISO-2022-JP版という手もありますが・・。
        • 21772
        • 69 Posts
        Zeroさん お返事ありがとうございます。

        早速ISO-2002-JP版を使わせて頂きましたが 同じ様なエラーが出て
        しまいます。

        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « PHP Parse Error »

        PHP error debug
        Error: mb_send_mail() [function.mb-send-mail]: Unsupported charset ""iso-2022-jp"" - will be regarded as ascii
        Error type/ Nr.: Warning - 2
        File: /var/www/html/modx/manager/includes/controls/class.phpmailer.php
        Line: 438
        Line 438 source: $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);

        前回と同様に $rt = @mail($to, $this->EncodeHeader($this->Subject), $body);
        $headerを取ってしまうと、エラー無しでメールは送信できますが、subjectが文字化けてしまいます。
        また $rt = @mb_send_mail($to, $this->Subject, $body); にすると、文字化けせずにメール
        出来ます。

        http://sb.xrea.com/archive/index.php/t-10440.htmlの症状と同じだと思います。

        もう少し調べて見たいのですが、PHPの事が良く分からないので何か簡単なデバック方法はないのでしょうか?
        ステップで、コードを追いかけられたら、分かりやすいのですが。

          • 6158
          • 224 Posts
          こんばんは。(8/13)

          Quote from: nori at Jul 21, 2007, 11:31 PM

          Error: mb_send_mail() [function.mb-send-mail]: Unsupported charset ""UTF-8"" - will be regarded as ascii

          Quote from: nori at Jul 22, 2007, 09:04 AM

          Error: mb_send_mail() [function.mb-send-mail]: Unsupported charset ""iso-2022-jp"" - will be regarded as ascii

          両方とも double quotation (") が文字コードの前後に2つずつ付いてます。
          これが解決のヒントだと思います。

          処理の段階では UTF-8, ISO-2022-JP と扱いたいのに、渡された文字列は
          「"UTF-8"」「"ISO-2022-JP"」という double quotation の付いた文字列が渡
          されている。

          それで double quotation の付いた「"UTF-8"」も「"ISO-2022-JP"」も、
          Unsupported charset だよ、と言ってるのでは。

          今日中に終わらせなきゃならないことやってるので、後はお任せします。
            • 33488
            • 429 Posts
            custerさんのヒントで
            phpmailerの下記のところですかね

            $result .= sprintf("Content-Type: %s; charset=\"%s\"",
            $this->ContentType, $this->CharSet);

            これのCharsetのところの”を外しちゃえばいけるかも・・・
              • 21772
              • 69 Posts
              custerさん Zeroさん

              ありがとうございます。
              custerさんのご指摘通りやはり原因としては、 文字コードの前についているダブルクォート(") の
              問題でした。

              そこでZeroさんの指摘の場所 class.phpmailer.phpの815行目付近(オリジナルが無くなって
              しまって正確なラインが分からなくなりました。)
                              $result .= sprintf("Content-Type: %s; charset=%s",
                                                  $this->ContentType, $this->CharSet);
              

              のコードを上記のように修正して、エラーは発生しなくなりました。

              ただ私の環境では、class.phpmailer.phpの438行目が下記の場合
              やっぱりSubjectが文字化けしてしまいますので
              $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);  
              

              @mailを@mb_send_mailに変更する事で、Subject文字化けに対応しています。
                • 33488
                • 429 Posts
                んーー、PHP5の仕様周りなんでしょうか・・・
                近々、PHP5の環境に移そうかと計画中なので、もし、トライすることがあったら調査してみます。

                結構、関数仕様とか変わっているところがあるのかも