CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 徽标和商标
  • 商业解决方案
  • 周边商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题(Github)
    • 烘焙坊
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
      • Exception
      • Transport
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

类 Message

电子邮件消息类。

此类用于发送基于 https://www.rfc-editor.org/rfc/rfc2822.txt 中概述的标准的互联网消息格式。

命名空间: Cake\Mailer

常量

  • 字符串
    EMAIL_PATTERN ¶
    '/^((?:[\\p{L}0-9.!#$%&\'*+\\/=?^_`{|}~-]+)*@[\\p{L}0-9-._]+)$/ui'

    保存用于电子邮件验证的正则表达式模式。

  • 整数
    LINE_LENGTH_MUST ¶
    998

    行长度 - 不得超过 - RFC 2822 - 2.1.1

  • 整数
    LINE_LENGTH_SHOULD ¶
    78

    行长度 - 不应超过 - RFC 2822 - 2.1.1

  • 字符串
    MESSAGE_BOTH ¶
    'both'

    消息类型 - BOTH

  • 字符串
    MESSAGE_HTML ¶
    'html'

    消息类型 - HTML

  • 字符串
    MESSAGE_TEXT ¶
    'text'

    消息类型 - TEXT

属性摘要

  • $appCharset protected
    字符串|空

    应用程序范围的字符集,用于编码头和主体

  • $attachments protected
    数组<字符串, 数组>

    应该附加到电子邮件的文件列表。

  • $bcc protected
    数组

    密件抄送

  • $boundary protected
    字符串|空

    如果设置,则用于多部分 MIME 消息的边界。

  • $cc protected
    数组

    抄送

  • $charset protected
    字符串

    发送电子邮件正文的字符集。

  • $charset8bit protected
    列表<字符串>

    8 位字符集

  • $contentTypeCharset protected
    数组<字符串, 字符串>

    定义 Content-Type 字符集名称

  • $domain protected
    字符串

    用于 messageId 生成的域名。需要为 CLI 邮件手动设置,因为 env('HTTP_HOST') 为空。

  • $emailFormat protected
    字符串

    电子邮件应该以什么格式发送。

  • $emailFormatAvailable protected
    列表<字符串>

    可用的发送格式。

  • $emailPattern protected
    字符串|空

    用于电子邮件验证的正则表达式。

  • $from protected
    数组

    发送电子邮件的邮件地址。

  • $headerCharset protected
    字符串|空

    发送电子邮件头的字符集。如果为空,则使用 $charset 属性作为默认值。

  • $headers protected
    数组

    用户定义头的关联数组。键将根据 RFC2822 第 4.7.5 节添加前缀 'X-'。

  • $htmlMessage protected
    字符串

    HTML 消息。

  • $message protected
    数组

    要发送的最终消息。

  • $messageId protected
    字符串|布尔值

    消息 ID。

  • $priority protected
    整数|空

    包含电子邮件的可选优先级。

  • $readReceipt protected
    数组

    回执电子邮件。

  • $replyTo protected
    数组

    收件人将回复的电子邮件列表。

  • $returnPath protected
    数组

    如果出现任何错误,将使用的邮件地址,例如:

    • 远程邮件服务器关闭
    • 远程用户已超出配额
    • 未知用户
  • $sender protected
    数组

    发件人电子邮件。

  • $serializableProperties protected
    列表<字符串>

    可以序列化的属性。

  • $subject protected
    字符串

    电子邮件的主题。

  • $textMessage protected
    字符串

    文本消息。

  • $to protected
    数组

    电子邮件的收件人。

  • $transferEncoding protected
    字符串|空

    使用的电子邮件传输编码。如果为空,则使用 $charset 属性来确定传输编码。

  • $transferEncodingAvailable protected
    列表<字符串>

    可用于设置传输的编码。

方法摘要

  • __construct() public

    构造函数

  • __serialize() public

    用于序列化 Message 对象的魔术方法。

  • __unserialize() public

    用于重建 Message 对象的魔术方法。

  • addAttachments() public

    添加附件

  • addBcc() public

    添加 "bcc" 地址。

  • addCc() public

    添加 "cc" 地址。

  • addEmail() protected

    添加电子邮件

  • addHeaders() public

    为消息添加头

  • addReplyTo() public

    添加 "Reply-To" 地址。

  • addTo() public

    添加 "To" 地址。

  • attachFiles() protected

    通过在边界内添加文件内容来附加非嵌入文件。

  • attachInlineFiles() protected

    将内联/嵌入文件附加到消息。

  • createBoundary() protected

    创建唯一的边界标识符

  • createFromArray() public

    从序列化配置配置电子邮件实例对象。

  • decodeForHeader() protected

    解码指定的字符串

  • encodeForHeader() protected

    使用当前字符集编码指定的字符串。

  • encodeString() protected

    如果 App.encoding 值不同且存在 mb_convert_encoding 函数,则将一个字符集的字符串转换为另一个字符集。

  • formatAddress() protected

    格式化地址

  • generateMessage() protected

    生成完整消息。

  • getAttachments() public

    获取电子邮件消息的附件。

  • getBcc() public

    获取 "bcc" 地址。

  • getBody() public

    以数组形式获取生成的邮件正文。

  • getBodyHtml() public

    获取消息的 HTML 正文。

  • getBodyString() public

    以字符串形式获取生成的正文。

  • getBodyText() public

    获取消息的文本正文。

  • getBodyTypes() public

    获取此电子邮件消息中的正文类型。

  • getCc() public

    获取 "cc" 地址。

  • getCharset() public

    字符集获取器。

  • getContentTransferEncoding() 公共

    根据设置的 transferEncoding 或 charset 返回 Content-Transfer Encoding 值。

  • getContentTypeCharset() 公共

    返回 Content-Type 的 charset 值。

  • getDomain() 公共

    获取域。

  • getEmailFormat() 公共

    获取电子邮件格式。

  • getEmailPattern() 公共

    EmailPattern 设置器/获取器

  • getFrom() 公共

    获取“来自”地址。

  • getHeaderCharset() 公共

    HeaderCharset 获取器。

  • getHeaders() 公共

    获取标题列表。

  • getHeadersString() 公共

    获取标题字符串。

  • getMessageId() 公共

    获取消息 ID。

  • getOriginalSubject() 公共

    获取原始主题(不进行编码)。

  • getPriority() 公共

    获取优先级。

  • getReadReceipt() 公共

    获取回执(Disposition-Notification-To 标头)。

  • getReplyTo() 公共

    获取“回复”地址。

  • getReturnPath() 公共

    获取回退路径。

  • getSender() 公共

    获取“发件人”地址。有关完整解释,请参阅下面的 RFC 链接。

  • getSubject() 公共

    获取主题。

  • getTo() 公共

    获取“收件人”地址

  • getTransferEncoding() 公共

    TransferEncoding 获取器。

  • jsonSerialize() 公共

    将电子邮件对象序列化为可以本地序列化并重新使用以克隆此电子邮件实例的值。

  • readFile() 受保护

    读取文件内容并返回文件的 base64 版本。

  • reset() 公共

    重置所有内部变量,以便能够发送新电子邮件。

  • setAttachments() 公共

    将附件添加到电子邮件消息中。

  • setBcc() 公共

    设置“密件抄送”地址。

  • setBody() 公共

    设置消息正文。

  • setBodyHtml() 公共

    设置消息的 HTML 正文。

  • setBodyText() 公共

    设置消息的文本正文。

  • setCc() 公共

    设置“抄送”地址。

  • setCharset() 公共

    Charset 设置器。

  • setConfig() 公共

    设置此实例的配置。

  • setDomain() 公共

    设置域。

  • setEmail() 受保护

    设置电子邮件

  • setEmailFormat() 公共

    设置电子邮件格式。

  • setEmailPattern() 公共

    EmailPattern 设置器/获取器

  • setEmailSingle() 受保护

    仅设置一个电子邮件

  • setFrom() 公共

    设置“来自”地址。

  • setHeaderCharset() 公共

    HeaderCharset 设置器。

  • setHeaders() 公共

    设置消息的标头。

  • setMessageId() 公共

    设置消息 ID。

  • setPriority() 公共

    设置优先级。

  • setReadReceipt() 公共

    设置回执(Disposition-Notification-To 标头)。

  • setReplyTo() 公共

    设置“回复”地址。

  • setReturnPath() 公共

    设置回退路径。

  • setSender() 公共

    设置“发件人”地址。有关完整解释,请参阅下面的 RFC 链接。

  • setSubject() 公共

    设置主题。

  • setTo() 公共

    设置“收件人”地址。

  • setTransferEncoding() 公共

    TransferEncoding 设置器。

  • validateEmail() 受保护

    验证电子邮件地址

  • wrap() 受保护

    包装消息以遵循 RFC 2822 - 2.1.1

方法详情

__construct() ¶ 公共

__construct(array<string, mixed>|null $config = null)

构造函数

参数
array<string, mixed>|null $config 可选

配置数组或从 app.php 加载配置的字符串

__serialize() ¶ 公共

__serialize(): array

用于序列化 Message 对象的魔术方法。

返回
数组

__unserialize() ¶ 公共

__unserialize(array $data): void

用于重建 Message 对象的魔术方法。

参数
array $data

数据数组。

返回
void

addAttachments() ¶ 公共

addAttachments(array $attachments): $this

添加附件

参数
array $attachments

文件名数组。

返回
$this
抛出
InvalidArgumentException
另请参阅
\Cake\Mailer\Email::setAttachments()

addBcc() ¶ 公共

addBcc(array|string $email, string|null $name = null): $this

添加 "bcc" 地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

addCc() ¶ 公共

addCc(array|string $email, string|null $name = null): $this

添加 "cc" 地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

addEmail() ¶ 受保护

addEmail(string $varName, array|string $email, string|null $name): $this

添加电子邮件

参数
string $varName

属性名称

array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name

名称

返回
$this
抛出
InvalidArgumentException

addHeaders() ¶ 公共

addHeaders(array $headers): $this

为消息添加头

参数
array $headers

要设置的标头。

返回
$this

addReplyTo() ¶ 公共

addReplyTo(array|string $email, string|null $name = null): $this

添加 "Reply-To" 地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

addTo() ¶ 公共

addTo(array|string $email, string|null $name = null): $this

添加 "To" 地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

attachFiles() ¶ 受保护

attachFiles(string|null $boundary = null): list<string>

通过在边界内添加文件内容来附加非嵌入文件。

参数
string|null $boundary 可选

要使用的边界。如果为 null,将默认为 $this->boundary

返回
列表<字符串>

attachInlineFiles() ¶ 受保护

attachInlineFiles(string|null $boundary = null): list<string>

将内联/嵌入文件附加到消息。

参数
string|null $boundary 可选

要使用的边界。如果为 null,将默认为 $this->boundary

返回
列表<字符串>

createBoundary() ¶ 受保护

createBoundary(): void

创建唯一的边界标识符

返回
void

createFromArray() ¶ 公共

createFromArray(array<string, mixed> $config): $this

从序列化配置配置电子邮件实例对象。

参数
array<string, mixed> $config

电子邮件配置数组。

返回
$this

decodeForHeader() ¶ 受保护

decodeForHeader(string $text): string

解码指定的字符串

参数
string $text

要解码的字符串

返回
字符串

encodeForHeader() ¶ 受保护

encodeForHeader(string $text): string

使用当前字符集编码指定的字符串。

参数
string $text

要编码的字符串

返回
字符串

encodeString() ¶ 受保护

encodeString(string $text, string $charset): string

如果 App.encoding 值不同且存在 mb_convert_encoding 函数,则将一个字符集的字符串转换为另一个字符集。

参数
string $text

要转换的文本

string $charset

目标编码

返回
字符串

formatAddress() ¶ 受保护

formatAddress(array $address): array

格式化地址

如果地址包含非字母数字/空格字符,它将被引用,因为诸如 : 和 , 之类的字符已知会在地址标头字段中导致问题。

参数
array $address

要格式化的地址。

返回
数组

generateMessage() ¶ 受保护

generateMessage(): list<string>

生成完整消息。

返回
列表<字符串>

getAttachments() ¶ 公共

getAttachments(): array<string, array>

获取电子邮件消息的附件。

返回
数组<字符串, 数组>

getBcc() ¶ 公共

getBcc(): array

获取 "bcc" 地址。

返回
数组

getBody() ¶ 公共

getBody(): array

以数组形式获取生成的邮件正文。

返回
数组

getBodyHtml() ¶ 公共

getBodyHtml(): string

获取消息的 HTML 正文。

返回
字符串

getBodyString() ¶ 公共

getBodyString(string $eol = "\r\n"): string

以字符串形式获取生成的正文。

参数
string $eol 可选

用于拼接的换行符字符串。

返回
字符串
另请参阅
Message::getBody()

getBodyText() ¶ 公共

getBodyText(): string

获取消息的文本正文。

返回
字符串

getBodyTypes() ¶ 公共

getBodyTypes(): array

获取此电子邮件消息中的正文类型。

返回
数组

getCc() ¶ 公共

getCc(): array

获取 "cc" 地址。

返回
数组

getCharset() ¶ public

getCharset(): string

字符集获取器。

返回
字符串

getContentTransferEncoding() ¶ public

getContentTransferEncoding(): string

根据设置的 transferEncoding 或 charset 返回 Content-Transfer Encoding 值。

返回
字符串

getContentTypeCharset() ¶ public

getContentTypeCharset(): string

返回 Content-Type 的 charset 值。

检查回退/兼容性类型,包括针对旧版日语字符集的解决方法。

返回
字符串

getDomain() ¶ public

getDomain(): string

获取域。

返回
字符串

getEmailFormat() ¶ public

getEmailFormat(): string

获取电子邮件格式。

返回
字符串

getEmailPattern() ¶ public

getEmailPattern(): string|null

EmailPattern 设置器/获取器

返回
字符串|空

getFrom() ¶ public

getFrom(): array

获取“来自”地址。

返回
数组

getHeaderCharset() ¶ public

getHeaderCharset(): string

HeaderCharset 获取器。

返回
字符串

getHeaders() ¶ public

getHeaders(array<int|string, string> $include = []): array<string, string>

获取标题列表。

包括

  • 发件人
  • 回复地址
  • 回执
  • 发件人地址
  • 收件人
  • 抄送
  • 密送
  • 主题
参数
array<int|string, string> $include 可选

标头列表。

返回
数组<字符串, 字符串>

getHeadersString() ¶ public

getHeadersString(list<string> $include = [], string $eol = "\r\n", Closure|null $callback = null): string

获取标题字符串。

参数
list<string> $include 可选

标头列表。

string $eol 可选

用于连接标头的换行符字符串。

Closure|null $callback 可选

在字符串化之前对每个标头值运行的回调。

返回
字符串
另请参阅
Message::getHeaders()

getMessageId() ¶ public

getMessageId(): string|bool

获取消息 ID。

返回
字符串|布尔值

getOriginalSubject() ¶ public

getOriginalSubject(): string

获取原始主题(不进行编码)。

返回
字符串

getPriority() ¶ public

getPriority(): int|null

获取优先级。

返回
整数|空

getReadReceipt() ¶ public

getReadReceipt(): array

获取回执(Disposition-Notification-To 标头)。

返回
数组

getReplyTo() ¶ public

getReplyTo(): array

获取“回复”地址。

返回
数组

getReturnPath() ¶ public

getReturnPath(): array

获取回退路径。

返回
数组

getSender() ¶ public

getSender(): array

获取“发件人”地址。有关完整解释,请参阅下面的 RFC 链接。

返回
数组
链接
https://tools.ietf.org/html/rfc2822.html#section-3.6.2

getSubject() ¶ public

getSubject(): string

获取主题。

返回
字符串

getTo() ¶ public

getTo(): array

获取“收件人”地址

返回
数组

getTransferEncoding() ¶ public

getTransferEncoding(): string|null

TransferEncoding 获取器。

返回
字符串|空

jsonSerialize() ¶ public

jsonSerialize(): array

将电子邮件对象序列化为可以本地序列化并重新使用以克隆此电子邮件实例的值。

返回
数组
抛出
Exception
当视图变量对象无法正确序列化时。

readFile() ¶ protected

readFile(Psr\Http\Message\UploadedFileInterface|string $file): string

读取文件内容并返回文件的 base64 版本。

参数
Psr\Http\Message\UploadedFileInterface|string $file

要读取的文件的绝对路径或 UploadedFileInterface 实例。

返回
字符串

reset() ¶ public

reset(): $this

重置所有内部变量,以便能够发送新电子邮件。

返回
$this

setAttachments() ¶ public

setAttachments(array $attachments): $this

将附件添加到电子邮件消息中。

附件可以根据您需要的控制程度以几种形式定义。

附加单个文件

$this->setAttachments('path/to/file');

使用不同的文件名附加文件

$this->setAttachments(['custom_name.txt' => 'path/to/file.txt']);

附加文件并指定其他属性

$this->setAttachments(['custom_name.png' => [
     'file' => 'path/to/file',
     'mimetype' => 'image/png',
     'contentId' => 'abc123',
     'contentDisposition' => false
   ]
]);

从字符串附加文件并指定其他属性

$this->setAttachments(['custom_name.png' => [
     'data' => file_get_contents('path/to/file'),
     'mimetype' => 'image/png'
   ]
]);

contentId 键允许您指定内嵌附件。在您的电子邮件文本中,您可以使用 <img src="cid:abc123"> 来内嵌显示图像。

contentDisposition 键允许您禁用 Content-Disposition 标头,这可以提高与 Outlook 电子邮件客户端的附件兼容性。

参数
array $attachments

文件名数组。

返回
$this
抛出
InvalidArgumentException

setBcc() ¶ public

setBcc(array|string $email, string|null $name = null): $this

设置“密件抄送”地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

setBody() ¶ public

setBody(array<string, string> $content): $this

设置消息正文。

参数
array<string, string> $content

内容数组,键为“text”和/或“html”,分别包含对应类型的字符串内容。

返回
$this

setBodyHtml() ¶ public

setBodyHtml(string $content): $this

设置消息的 HTML 正文。

参数
string $content

内容字符串

返回
$this

setBodyText() ¶ public

setBodyText(string $content): $this

设置消息的文本正文。

参数
string $content

内容字符串

返回
$this

setCc() ¶ public

setCc(array|string $email, string|null $name = null): $this

设置“抄送”地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

setCharset() ¶ public

setCharset(string $charset): $this

Charset 设置器。

参数
string $charset

字符集。

返回
$this

setConfig() ¶ public

setConfig(array<string, mixed> $config): $this

设置此实例的配置。

参数
array<string, mixed> $config

配置数组。

返回
$this

setDomain() ¶ public

setDomain(string $domain): $this

设置域。

域作为顶级(@ 之后的部分)。

参数
string $domain

手动设置 CLI 邮件的域。

返回
$this

setEmail() ¶ protected

setEmail(string $varName, array|string $email, string|null $name): $this

设置电子邮件

参数
string $varName

属性名称

array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name

名称

返回
$this
抛出
InvalidArgumentException

setEmailFormat() ¶ public

setEmailFormat(string $format): $this

设置电子邮件格式。

参数
string $format

格式化字符串。

返回
$this
抛出
InvalidArgumentException

setEmailPattern() ¶ public

setEmailPattern(string|null $regex): $this

EmailPattern 设置器/获取器

参数
string|null $regex

用于电子邮件地址验证的模式,为 null 则取消设置模式并使用 filter_var()。

返回
$this

setEmailSingle() ¶ protected

setEmailSingle(string $varName, array|string $email, string|null $name, string $throwMessage): $this

仅设置一个电子邮件

参数
string $varName

属性名称

array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name

名称

string $throwMessage

异常消息

返回
$this
抛出
InvalidArgumentException

setFrom() ¶ public

setFrom(array|string $email, string|null $name = null): $this

设置“来自”地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this
抛出
InvalidArgumentException

setHeaderCharset() ¶ public

setHeaderCharset(string|null $charset): $this

HeaderCharset 设置器。

参数
string|null $charset

字符集。

返回
$this

setHeaders() ¶ public

setHeaders(array $headers): $this

设置消息的标头。

参数
array $headers

包含要设置的标头的关联数组。

返回
$this

setMessageId() ¶ public

setMessageId(string|bool $message): $this

设置消息 ID。

参数
string|bool $message

如果为真,则生成新的 Message-ID,如果为假,则忽略(不发送到电子邮件),如果为字符串,则设置为 Message-ID。

返回
$this
抛出
InvalidArgumentException

setPriority() ¶ public

setPriority(int|null $priority): $this

设置优先级。

参数
int|null $priority

1(最高)到 5(最低)。

返回
$this

setReadReceipt() ¶ public

setReadReceipt(array|string $email, string|null $name = null): $this

设置回执(Disposition-Notification-To 标头)。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this
抛出
InvalidArgumentException

setReplyTo() ¶ public

setReplyTo(array|string $email, string|null $name = null): $this

设置“回复”地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this
抛出
InvalidArgumentException

setReturnPath() ¶ public

setReturnPath(array|string $email, string|null $name = null): $this

设置回退路径。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this
抛出
InvalidArgumentException

setSender() ¶ public

setSender(array|string $email, string|null $name = null): $this

设置“发件人”地址。有关完整解释,请参阅下面的 RFC 链接。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this
抛出
InvalidArgumentException
链接
https://tools.ietf.org/html/rfc2822.html#section-3.6.2

setSubject() ¶ public

setSubject(string $subject): $this

设置主题。

参数
string $subject

主题字符串。

返回
$this

setTo() ¶ public

setTo(array|string $email, string|null $name = null): $this

设置“收件人”地址。

参数
array|string $email

包含电子邮件的字符串,包含电子邮件作为键、名称作为值的数组,或包含电子邮件作为值的数组(没有名称)。

string|null $name 可选

名称

返回
$this

setTransferEncoding() ¶ public

setTransferEncoding(string|null $encoding): $this

TransferEncoding 设置器。

参数
string|null $encoding

设置的编码。

返回
$this
抛出
InvalidArgumentException

validateEmail() ¶ protected

validateEmail(string $email, string $context): void

验证电子邮件地址

参数
string $email

要验证的电子邮件地址。

string $context

设置了哪个属性。

返回
void
抛出
InvalidArgumentException
如果电子邮件地址验证失败。

wrap() ¶ protected

wrap(string|null $message = null, int $wrapLength = self::LINE_LENGTH_MUST): list<string>

包装消息以遵循 RFC 2822 - 2.1.1

参数
string|null $message optional

要包装的消息。

int $wrapLength optional

行长。

返回
列表<字符串>

属性详细信息

$appCharset ¶ protected

应用程序范围的字符集,用于编码头和主体

类型
字符串|空

$attachments ¶ protected

应该附加到电子邮件的文件列表。

仅绝对路径。

类型
数组<字符串, 数组>

$bcc ¶ protected

密件抄送

应该收到电子邮件副本的电子邮件列表。收件人无法看到此列表。

类型
数组

$boundary ¶ protected

如果设置,则用于多部分 MIME 消息的边界。

类型
字符串|空

$cc ¶ protected

抄送

应该收到电子邮件副本的电子邮件列表。收件人将能够看到此列表。

类型
数组

$charset ¶ protected

发送电子邮件正文的字符集。

类型
字符串

$charset8bit ¶ protected

8 位字符集

类型
列表<字符串>

$contentTypeCharset ¶ protected

定义 Content-Type 字符集名称

类型
数组<字符串, 字符串>

$domain ¶ protected

用于 messageId 生成的域名。需要为 CLI 邮件手动设置,因为 env('HTTP_HOST') 为空。

类型
字符串

$emailFormat ¶ protected

电子邮件应该以什么格式发送。

类型
字符串

$emailFormatAvailable ¶ protected

可用的发送格式。

类型
列表<字符串>

$emailPattern ¶ protected

用于电子邮件验证的正则表达式。

如果为 null,将使用 filter_var()。使用 emailPattern() 方法设置自定义模式。

类型
字符串|空

$from ¶ protected

发送电子邮件的邮件地址。

类型
数组

$headerCharset ¶ protected

发送电子邮件头的字符集。如果为空,则使用 $charset 属性作为默认值。

类型
字符串|空

$headers ¶ protected

用户定义头的关联数组。键将根据 RFC2822 第 4.7.5 节添加前缀 'X-'。

类型
数组

$htmlMessage ¶ protected

HTML 消息。

类型
字符串

$message ¶ protected

要发送的最终消息。

类型
数组

$messageId ¶ protected

消息 ID。

类型
字符串|布尔值

$priority ¶ protected

包含电子邮件的可选优先级。

类型
整数|空

$readReceipt ¶ protected

回执电子邮件。

类型
数组

$replyTo ¶ protected

收件人将回复的电子邮件列表。

类型
数组

$returnPath ¶ protected

如果出现任何错误,将使用的邮件地址,例如:

  • 远程邮件服务器关闭
  • 远程用户已超出配额
  • 未知用户
类型
数组

$sender ¶ protected

发件人电子邮件。

类型
数组

$serializableProperties ¶ protected

可以序列化的属性。

类型
列表<字符串>

$subject ¶ protected

电子邮件的主题。

类型
字符串

$textMessage ¶ protected

文本消息。

类型
字符串

$to ¶ protected

电子邮件的收件人。

类型
数组

$transferEncoding ¶ protected

使用的电子邮件传输编码。如果为空,则使用 $charset 属性来确定传输编码。

类型
字符串|空

$transferEncodingAvailable ¶ protected

可用于设置传输的编码。

类型
列表<字符串>
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 徽标和商标
  • 社区
  • 参与进来
  • 问题(Github)
  • 烘焙坊
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成