0

私はphpメール機能を介してメールを送信するために次の構成を使用しています:

function sendInvoiceEmail() {

顧客の電子メールを取得

        $recieverEmail = xyz@test.com; //Valid Email ID
        $recieverName = xyz; 

メール構成配列の作成

    $emailConfig = array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'abc@abc.com',   //Valid Email ID
            'smtp_pass' => 'password',      //Valid password
            'mailtype' => 'html', //text or html
            'charset' => 'iso-8859-1',
        );

メール情報を設定する

        $from = array('email' => 'abc@abc.com', 'name' => 'Testing');

    $to = array('email' => $recieverEmail, 'name' => $recieverName);
        $subject = "Test Mail for Invoice ";

        $message = "Test Message for Invoice";

CodeIgniter メール ライブラリを読み込む

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

より良い結果を得るために改行文字を設定する必要がある場合があります

        $this->email->set_newline("\r\n");

メールの設定

        $this->email->from($from['email'], $from['name']);
        $this->email->to($to['email'], $to['name']);
        $this->email->subject($subject);
        $this->email->message($message);

メールを送信する準備ができて、メールが正常に送信されたかどうかを確認します

        if ($this->email->send()) {
            return true;
        } else {
            show_error($this->email->print_debugger());                
        }
    }

PHP 5.3.9 バージョンと wampserver を使用していますが、次のエラーが発生します。

An Error Was Encountered

The following SMTP error was encountered: 52770504 Unable to find the socket 
transport "ssl" - did you forget to enable it when you configured PHP?
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:

from: 

The following SMTP error was encountered:
Unable to send data: RCPT TO:

to: 

The following SMTP error was encountered:
Unable to send data: DATA

data: 

The following SMTP error was encountered:
Unable to send data: User-Agent: CodeIgniter Date: Thu, 27 Dec 2012 16:50:28 
+0530 From: "Invoice Tester" Return-Path: To: df@df.kl Subject: =?iso-8859-1?Q?Test_Mail_for_Invoice_?= Reply-To: "sujit.singh@xpointers.com" X-Sender: sujit.singh@xpointers.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <50dc2efca4149@xpointers.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_50dc2efca4160" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_50dc2efca4160 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Test Message for Invoice --B_ALT_50dc2efca4160 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Test Message for Invoice --B_ALT_50dc2efca4160--
Unable to send data: .

The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to 

このメソッドを使用してメールを送信します。

4

2 に答える 2

2

「smtp_host」を「smtp.gmail.com」に変更してみてください

チェックアウト:SMTPエラー:SMTPホストに接続できませんでした

SSLエラーを確認してみてください。

エラーから、ご使用のバージョンのPHPがsslでコンパイルされていない可能性があります。

走る:

<?php
phpinfo();
?>

そして、「ConfigureCommand」に「--with-openssl =/usr」のようなものがあるかどうかを確認します。また、「登録済みストリームソケットトランスポート」セクションにsslがリストされていることを確認してください。

于 2012-12-27T11:43:44.223 に答える
1

wampserver について PHP 拡張機能に設定があることを知っているので、wampserver を使用している場合は、次の手順を実行できます。

1) WampSever トレイ アイコンに移動します

2) PHP 拡張機能に移動します。

3) 検索php_openssl

4) チェックされていない場合は、チェック済みとしてマークします ( php_openssl)

それ以外の場合は、マイケルの回答を参照できます:)

それがあなたを助けることを願っています。

于 2012-12-27T11:41:18.603 に答える