Codeigniter-sending-email
CodeIgniter-メールの送信
CodeIgniterでメールを送信するのははるかに簡単です。 CodeIgniterで電子メールに関する設定も構成します。 CodeIgniterは、メールを送信するための次の機能を提供します-
- 複数のプロトコル-メール、Sendmail、およびSMTP
- SMTPのTLSおよびSSL暗号化
- 複数の受信者
- CCおよびBCC
- HTMLまたはプレーンテキストメール
- 添付ファイル
- ワードラッピング
- 優先順位
- BCCバッチモード。大きな電子メールリストを小さなBCCバッチに分割できます。 *メールデバッグツール
電子メールクラスには、電子メールの送信作業を簡素化する次の機能があります。
S.N. | Syntax | Parameters | Return | Return Type |
---|---|---|---|---|
1 | from($from[, $name = ''[, $return_path = NULL]]) |
|
CI_Email instance (method chaining) | CI_Email |
2 | reply_to($replyto[, $name = '']) |
$replyto (string) − E-mail address for replies
|
CI_Email instance (method chaining) | CI_Email |
2 | to($to) | $to (mixed) − Comma-delimited string or an array of e-mail addresses | CI_Email instance (method chaining) | CI_Email |
3 | cc($cc) | *$cc *(mixed) − Comma-delimited string or an array of e-mail addresses | CI_Email instance (method chaining) | CI_Email |
4 | bcc($bcc[, $limit = '']) |
|
CI_Email instance (method chaining) | CI_Email |
5 | subject($subject) | $subject (string) − E-mail subject line | CI_Email instance (method chaining) | CI_Email |
6 | message($body) | $body (string) − E-mail message body | CI_Email instance (method chaining) | CI_Email |
7 | set_alt_message($str) | *$str *(string) − Alternative e-mail message body | CI_Email instance (method chaining) | CI_Email |
8 | set_header($header, $value) |
|
CI_Email instance (method chaining) | CI_Email |
9 | clear([$clear_attachments = FALSE]) | $clear_attachments (bool) – Whether or not to clear attachments | CI_Email instance (method chaining) | CI_Email |
10 | send([$auto_clear = TRUE]) | *$auto_clear *(bool) − Whether to clear message data automatically | CI_Email instance (method chaining) | CI_Email |
11 | attach($filename[, $disposition = [, $newname = NULL[, $mime = ]]]) |
|
CI_Email instance (method chaining) | CI_Email |
12 | attachment_cid($filename) | *$filename *(string) − Existing attachment filename | Attachment Content-ID or FALSE if not found | string |
メールを送る
CodeIgniterを使用して電子メールを送信するには、まず、次を使用して電子メールライブラリをロードする必要があります-
ライブラリをロードした後、次の関数を実行して、電子メールを送信するために必要な要素を設定します。* from()関数は、電子メールの送信元および to()関数の使用元を設定するために使用されます-電子メールの送信先。 * subject()*および message()*関数は、電子メールの件名とメッセージを設定するために使用されます。
その後、以下に示す* send()*関数を実行してメールを送信します。
例
コントローラーファイル Email_controller.php を作成し、 application/controller/Email_controller.php に保存します。
次のリンクにアクセスして、上記の例を実行します。 yoursite.comをサイトのURLに置き換えます。