previous導入 (Previous) (Next) Mail::send()next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Mail::factory()

Mail::factory() – メーラインスタンスを作成する

Synopsis

require_once 'Mail.php';

object &factory ( string $backend , array $params = array() )

Description

バックエンド毎のmailクラスのインスタンスを生成します。

Parameter

  • string $backend - バックエンド名 "mail""smtp""sendmail"

  • array $params - バックエンド固有ののパラメータの配列。

    バックエンド毎のパラメータ一覧

    • mail

      • セーフモードが無効の場合、 $params は PHP mail() 関数の 5 番引数として渡されるでしょう。 $params が配列の場合、 その要素はスペース区切りの文字列として連結されるでしょう。

    • sendmail

      • $params["sendmail_path"] - システム上での sendmail プログラムの場所、デフォルトは、 /usr/bin/sendmail

      • $params["sendmail_args"] - sendmail プログラムへ渡す追加パラメータ。 デフォルトは -i

    • smtp

      • $params["host"] - 接続するサーバ名。 デフォルトは、localhost です。

      • $params["port"] - 接続するポート番号。 デフォルトは、25 です。

      • $params["auth"] - SMTP 認証を使用するかどうか。 デフォルトは FALSE です。

      • $params["username"] - SMTP 認証で使用するユーザ名。

      • $params["password"] - SMTP 認証で使用するパスワード。

      • $params["localhost"] - EHLO あるいは HELO を送信する際に使用する値。 デフォルトは localhost です。

      • $params["timeout"] - SMTP 接続のタイムアウト。 デフォルトは NULL (タイムアウトしない) です。

      • $params["verp"] - VERP を使用するかどうか。デフォルトは FALSE です。

      • $params["debug"] - SMTP デバッグモードを使用するかどうか。デフォルトは FALSE です。

      • $params["persist"] - SMTP 接続を、send() メソッドの複数回呼出しで持続させるかどうか指示します。

Return value

object - 特定の Mail インスタンス、 または失敗した場合は PEAR_Error オブジェクト。

Throws

Possible PEAR_Error values
エラーコード エラーメッセージ 意味 解決
NULL "Unable to find class for driver xxx " メーラーバックエンドクラスが見つかりません。 $backend パラメータのチェックをします。 もし正しい場合、Mail パッケージの再インストール、 または更新をします。

Note

This function should be called statically.

previous導入 (Previous) (Next) Mail::send()next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: Joe
There is hard-coded -f option in Mail_sendmail->send so it is impossible to set it using $params['sendmail_args']. It is hard-coded to -f$from.

In my case it caused 'X-Authentication-Warning' in mail headers.
Note by: shaun@shaunfreeman.co.uk
When sending mail via smtp be careful with the $params["auth"] option, the docs say it set it either to true or false, but in my case this didn't work and only when I set it to the actual authentication method of the server it worked. In my case I had to set it to:

$params["auth"] = "PLAIN";

This little problem had me going around in circles for 2 weeks!