1

お問い合わせフォームを設定しようとしていますが、CI の SMTP 構成で機能させるのに苦労しています。ただし、基本的な「メール」構成を試してみました。

簡単に言うと、次の単純なコードでテストを行っています。

    $config = array(
        'protocol' => 'smtp',
        'smtp_host' => 'smtp.1and1.es',
        'smtp_port' => 25,
        'smtp_user' => 'user@mysite.com', 
        'smtp_pass' => '********',
        'mailtype'  => 'text',
        'charset'   => 'utf-8',
        'wordwrap'  => true,
        'wrapchars' => 50            
    );

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

    $this->email->from('my_real_email_address@gmail.com');
    $this->email->to('my_real_email_address@gmail.com');
    $this->email->reply_to('my_real_email_address@gmail.com', 'John Doe');
    $this->email->subject('Message sent from the contact form in website');
    $this->email->message('Body of message...');

    if ($this->email->send()) {
            return true;
    }
    echo '<!--' . print_r($this->email->print_debugger(), true) . '-->'; 
    return false;

ホスティング プロバイダーに問い合わせたところ、すべての SMTP 構成が正しいです。また、私の電子メール アカウントが正常に機能していることも確認しました。

実際、私が選択した場合:

プロトコル => 'メール'

メッセージは問題なく配信されます。私の知る限り、php mail() 関数もホスティング プロバイダーの SMTP を使用しますが、単純にそれをサーバーに渡して忘れてしまいます。

代わりに、電子メールの送信を心配する SMTP 認証を使用したいと考えています。でも変えるだけで

プロトコル => 'smtp'

フォームを送信すると、多くの処理時間がかかり、最終的に次のデバッグ メッセージが表示されます。

220 smtp.1and1.es (mreu2) Welcome to Nemesis ESMTP server

hello:  The following SMTP error was encountered:
Failed to send AUTH LOGIN command. Error: 421 smtp.1and1.es connection timed out

from:  The following SMTP error was encountered:
to:  The following SMTP error was encountered: 
data:  The following SMTP error was encountered:  

The following SMTP error was encountered: 
Unable to send email using PHP SMTP.  Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Thu, 24 Jan 2013 18:51:31 +0100
From: <my_real_email_address@gmail.com>
Return-Path: <my_real_email_address@gmail.com>
To: my_real_email_address@gmail.com
Reply-To: "John Doe" <my_real_email_address@gmail.com>
Subject: =?utf-8?Q?Message_sent_from_the_contact_form_in_website?=
X-Sender: my_real_email_address@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <510174a33158d@gmail.com>
Mime-Version: 1.0


Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Body of message...

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

4

1 に答える 1

15

一重引用符を含む構成項目に問題があると報告されている人もいます:

$config['crlf'] = '\r\n';      //should be "\r\n"
$config['newline'] = '\r\n';   //should be "\r\n"

protocol => mailあなたのプロバイダーを使用していないことは確かです-サーバーから直接メールを送信します.

一重引用符の問題でない場合は、資格情報、ファイアウォール、または接続要件が正しくないことが問題である可能性があります (メール プロバイダーで TLS/SSL が必要な場合など)。

メール サーバーに接続して別のクライアントでメールを送信してみてください (telnet を使用できます: http://www.wikihow.com/Send-Email-Using-Telnetまたは Thunderbird など)、プロトコルが正しいことを確認します。

于 2013-01-24T19:19:30.977 に答える