Email 套件

Email 套件提供了一个介面使用 PHP 的 mail 函式、sendmail 或 SMTP來发送郵件。 套件支援:

安装

Email 套件已成为官方下载的一部分(自 1.1 版起)。 你将必須在应用程序配置或动態引入以啟用套件。

'always_load' => array(
	'packages' => array(
		'email',
	),
),

// 或在控制器中:

\Package::load('email');

配置

建立(或從套件複製)一个在 app/config/email.php 的配置档。并更改所需的配置。

請注意:Email 套件为你載入 email 配置,所以不需要自动載入它。

一般配置

參数 类型 預設 描述
defaults 陣列
array( /* default 配置陣列 */ )
每个設定組使用的預設設定。在你的設置組覆寫这些值。
default_setup 字串
'default'
如果沒有提供,使用的預設設定。
setups 陣列
array(
		'default' => array(),
	)
帶有一个預設設定的設定陣列。添加你自己的或修改預設設定組。

群組配置

參数 类型 預設 描述
useragent 字串
'FuelPHP, PHP 5.3 Framework'
使用者代理。
driver 字串
'mail'
使用的驅动程序。可以是 mail、smtp、sendmail、mailgun、mandrill 或 noop(只寫 log 記錄),必須为小寫。
is_html 布林
false
做为 HTML 電子郵件或普通郵件发送。
encode_headers 布林
true
是否對主題及接收者名稱進行编码。 需要 mbstring 擴充
charset 字串
'utf-8'
電子郵件訊息的字符集。
encoding 字串
'8bit'
電子郵件訊息编码。可以是 7bit、8bit、quoted-printable 和 base64。
priority 字串
\Email::P_NORMAL
電子郵件的優先權。可以是:
  • \Email::P_LOWEST
  • \Email::P_LOW
  • \Email::P_NORMAL
  • \Email::P_HIGH
  • \Email::P_HIGHEST
from.email 字串|false
false
使用它設定預設的 from 電子郵件地址。
from.name 字串|false
false
使用它設定預設的 from 名稱。
validate 布林
true
設定为false,如果你不想驗證地址。在发送時可能導致失敗。
auto_attach 布林
true
是否從一个 HTML 主體自动附加(背景)圖片。
generate_alt 布林
true
是否自动從 HTML 主體產生一个替代的主體。
wordwrap 整数|false
76
文字換行的大小。如果低於任何大於 0 的大小将換行。當使用 base64 或 quoted-printable 時,此設定将被忽略。
sendmail_path 字串
'/usr/sbin/sendmail'
sendmail 路徑。
smtp.host 字串
''
SMTP 主機。
smtp.port 整数
25
SMTP 埠。
smtp.username 字串
''
SMTP 帳號。
smtp.password 字串
''
SMTP 密码。
smtp.timeout 整数
5
SMTP 逾時。當 SMTP 伺服器在发送程序期間逾時時增加它。
smtp.starttls bool
false
SMTP 伺服器是否需要 STARTTLS 命令。
newline 字串
"\n"
換行。
attach_paths 陣列
array('');
附件路徑陣列。添加附件時, 驅动程序会在这些路徑尋找,并附加第一个发现的。 留下空 ('') 以允許絕對路徑。
return_path 字串|false
false
使用它設定預設的回傳路徑郵件地址。
remove_html_comments 布林
true
When true, all comments inside the HTML body will be stripped.
relative_protocol_replacement 字串|false
false
When set to a string, all relative protocol URI's (those starting with // instead of http://) will be replaced by the value you specify here. This allows you to convert them to http:// or https://, since some Email clients (Outlook!) do not support relative protocol URI's.
mandrill.key 字串
'api_key'
你的 Mandrill API 鑰匙。
mandrill.message_options 陣列
array()
Check Mandrill docs. (Look for message struct)
mandrill.send_options.async 布林
false
Enable a background sending mode
mandrill.send_options.ip_pool 字串
null
The name of the dedicated ip pool that should be used to send the message
mandrill.send_options.send_at 字串
null
When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format.

Make sure to install mandrill/mandrill composer package if you want to use the mandrill driver.

Mailgun 配置

參数 类型 預設 描述
key 字串
'YOUR KEY'
你的 mailgun 的 key。
domain 字串
'YOUR DOMAIN'
你網站的網域