4

メールに問題があります。HTML は問題ありませんが、メールを開くと、テキストとリンクにエラーがあり、いくつかの文字が = like に変更されています。

Thanks for joining . your log=n details are here ma=e sure you keep them safe.
To verify your email address, please follow this link:

 Finish your registration...

Link doesn't work? Copy the following link to your browser address bar:  http://www.myurl.com/dev=l/panel/auth/activate/123131/123131

Please verify your email within 123131 hours, otherwise your registration =ill become invalid and you will have to register again.

すべての画像とリンクでさえテキストが壊れています。{unwrap} と関係があると思っていましたが、役に立ちませんでした

これはconfig/email.phpです

$config['email_notification']['protocol'] = 'smtp';
$config['email_notification']['smtp_host'] = 'smtp.live.com';
$config['email_notification']['smtp_user'] = 'xxxxx';
$config['email_notification']['smtp_pass'] = 'xxxxxxx';
$config['email_notification']['smtp_port'] = '587';
$config['email_notification']['mailtype'] = 'html';
$config['email_notification']['charset'] = 'utf-8';
$config['email_notification']['wordwrap'] = false;
$config['email_notification']['smtp_crypto'] = 'tls';

これがコントローラーです

 $this->load->library('email');



    $this->email->initialize($this->config->item('email_notification'));
    $this->email->subject('Email Test');

    $this->email->set_newline("\r\n");
    $this->email->from('xxxxxx'); // change it to yours
    $this->email->to('xxxxx');
    $this->email->subject('Email Test');

    $data=array(
        'site_name'=>'tralalalal',
        'user_id'=>'123131',
        'new_email_key'=>'123131',
        'activation_period'=>'123131',
        'email'=>'123131',
        'title'=>'123131',

    );
    $this->email->message($this->load->view('email/activate_account/en',$data,true));

メール本文は

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
    /* Client-specific Styles */
#outlook a{padding:0;} /* Force Outlook to provide a "view in browser" button. */
body{width:100% !important;} .ReadMsgBody{width:100%;} .ExternalClass{width:100%;} /* Force Hotmail to display emails at full width */
body{-webkit-text-size-adjust:none;} /* Prevent Webkit platforms from changing default text sizes. */

    /* Reset Styles */
body{margin:0; padding:0;}
img{border:0; height:auto; line-height:100%; outline:none; text-decoration:none;}
table td{border-collapse:collapse;}
#backgroundTable{height:100% !important; margin:0; padding:0; width:100% !important;}
</style>
</head>
<body>

ありがとう

4

3 に答える 3

2

私は答えを見つけたので、誰かが同じ問題を抱えているなら

理由があります

この標準では
、1 行の文字数に 2 つの制限があります。文字の各行は 、CRLF
を除いて、998 文字を超えてはならず、78 文字を超えてはなりません。

998 文字の制限は、1 行で 998 文字を超える文字を処理できない Internet Message Format メッセージを送信、受信、または保存する多くの実装の制限によるものです。受信実装は、堅牢性のために行内の任意の多数の文字を処理するのに適しています。ただし、([RFC2821] のトランスポート要件に準拠して) 行ごとに CR と LF を含む 1000 文字を超えるメッセージを受け入れない実装が非常に多いため、実装がそのようなメッセージを作成しないことが重要です。

より保守的な 78 文字の推奨事項は、これらのメッセージを表示するユーザー インターフェイスの多くの実装に対応することです。これらの実装は 、 1 行あたり 78 文字を超える
表示を切り捨てたり、壊滅的に折り返す可能性があります。この 仕様の意図 (および、実際に情報が失われる場合は [RFC2821]の意図 )。繰り返しになりますが、この制限はメッセージに適用されますが、メッセージを表示する実装には負担がかかります



ここでコードを変更して、この制限を上書きします system/libraries/email.php

オリジナル

protected function _prep_quoted_printable($str, $charlim = '')
{
    // Set the character limit
    // Don't allow over 76, as that will make servers and MUAs barf
    // all over quoted-printable data
    if ($charlim == '' OR $charlim > '76')
    {
        $charlim = '76';
    }

クイックフィックス:)

protected function _prep_quoted_printable($str, $charlim = '')
{
    // Set the character limit
    // Don't allow over 76, as that will make servers and MUAs barf
    // all over quoted-printable data
    if ($charlim == '' OR $charlim > '76')
    {
        $charlim = '200';
    }
于 2013-02-17T01:13:06.053 に答える
0

問題は _prep_quoted_printable 関数にあると思います。幸いなことに、v5.3 の時点で、この関数のネイティブ PHP バージョンがあります。

Email クラスの _prep_quoted_printable のインスタンスを PHP ネイティブ関数の quoted_printable_encode に置き換えることで、同様の問題を解決できました。

これは、私の _build_message() が次のようになったことになります。

    /**
 * Build Final Body and attachments
 *
 * @access  protected
 * @return  void
 */
protected function _build_message()
{
    if ($this->wordwrap === TRUE  AND  $this->mailtype != 'html')
    {
        $this->_body = $this->word_wrap($this->_body);
    }

    $this->_set_boundaries();
    $this->_write_headers();

    $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
    $body = '';

    switch ($this->_get_content_type())
    {
        case 'plain' :

            $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
            $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();

            if ($this->_get_protocol() == 'mail')
            {
                $this->_header_str .= $hdr;
                $this->_finalbody = $this->_body;
            }
            else
            {
                $this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body;
            }

            return;

        break;
        case 'html' :

            if ($this->send_multipart === FALSE)
            {
                $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
                $hdr .= "Content-Transfer-Encoding: quoted-printable";
            }
            else
            {
                $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;

                $body .= $this->_get_mime_message() . $this->newline . $this->newline;
                $body .= "--" . $this->_alt_boundary . $this->newline;

                $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
                $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
                $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;

                $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
                $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
            }

            // $this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
            $this->_finalbody = $body . quoted_printable_encode($this->_body) . $this->newline . $this->newline;


            if ($this->_get_protocol() == 'mail')
            {
                $this->_header_str .= $hdr;
            }
            else
            {
                $this->_finalbody = $hdr . $this->_finalbody;
            }


            if ($this->send_multipart !== FALSE)
            {
                $this->_finalbody .= "--" . $this->_alt_boundary . "--";
            }

            return;

        break;
        case 'plain-attach' :

            $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;

            if ($this->_get_protocol() == 'mail')
            {
                $this->_header_str .= $hdr;
            }

            $body .= $this->_get_mime_message() . $this->newline . $this->newline;
            $body .= "--" . $this->_atc_boundary . $this->newline;

            $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
            $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;

            $body .= $this->_body . $this->newline . $this->newline;

        break;
        case 'html-attach' :

            $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;

            if ($this->_get_protocol() == 'mail')
            {
                $this->_header_str .= $hdr;
            }

            $body .= $this->_get_mime_message() . $this->newline . $this->newline;
            $body .= "--" . $this->_atc_boundary . $this->newline;

            $body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
            $body .= "--" . $this->_alt_boundary . $this->newline;

            $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
            $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
            $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;

            $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
            $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;

            // $body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
            $body .= quoted_printable_encode($this->_body) . $this->newline . $this->newline;
            $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;

        break;
    }

    $attachment = array();

    $z = 0;

    for ($i=0; $i < count($this->_attach_name); $i++)
    {
        $filename = $this->_attach_name[$i];
        $basename = basename($filename);
        $ctype = $this->_attach_type[$i];

        if ( ! file_exists($filename))
        {
            $this->_set_error_message('lang:email_attachment_missing', $filename);
            return FALSE;
        }

        $h  = "--".$this->_atc_boundary.$this->newline;
        $h .= "Content-type: ".$ctype."; ";
        $h .= "name=\"".$basename."\"".$this->newline;
        $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
        $h .= "Content-Transfer-Encoding: base64".$this->newline;

        $attachment[$z++] = $h;
        $file = filesize($filename) +1;

        if ( ! $fp = fopen($filename, FOPEN_READ))
        {
            $this->_set_error_message('lang:email_attachment_unreadable', $filename);
            return FALSE;
        }

        $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
        fclose($fp);
    }

    $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";


    if ($this->_get_protocol() == 'mail')
    {
        $this->_finalbody = $body;
    }
    else
    {
        $this->_finalbody = $hdr . $body;
    }

    return;
}
于 2016-07-01T09:30:28.380 に答える