PHP Interface yii\mail\MessageInterface

A message represents the settings and content of an email, such as the sender, recipient, subject, body, etc. Messages are sent by a [[\yii\mail\MailerInterface|mailer]], like the following, ~~~ Yii::$app->mailer->compose() ->setFrom('[email protected]') ->setTo($form->email) ->setSubject($form->subject) ->setTextBody('Plain text content') ->setHtmlBody('HTML content') ->send(); ~~~
See also: MailerInterface
Since: 2.0
Author: Paul Klimov ([email protected])
Afficher le fichier Open project: yiisoft/yii2 Interface Usage Examples

Méthodes publiques

Méthode Description
attach ( string $fileName, array $options = [] ) Attaches existing file to the email message.
attachContent ( string $content, array $options = [] ) Attach specified content as file for the email message.
embed ( string $fileName, array $options = [] ) : string Attach a file and return it's CID source.
embedContent ( string $content, array $options = [] ) : string Attach a content as file and return it's CID source.
getBcc ( ) : array Returns the Bcc (hidden copy receiver) addresses of this message.
getCc ( ) : array Returns the Cc (additional copy receiver) addresses of this message.
getCharset ( ) : string Returns the character set of this message.
getFrom ( ) : string Returns the message sender.
getReplyTo ( ) : string Returns the reply-to address of this message.
getSubject ( ) : string Returns the message subject.
getTo ( ) : array Returns the message recipient(s).
send ( yii\mail\MailerInterface $mailer = null ) : boolean Sends this email message.
setBcc ( string | array $bcc ) Sets the Bcc (hidden copy receiver) addresses of this message.
setCc ( string | array $cc ) Sets the Cc (additional copy receiver) addresses of this message.
setCharset ( string $charset ) Sets the character set of this message.
setFrom ( string | array $from ) Sets the message sender.
setHtmlBody ( string $html ) Sets message HTML content.
setReplyTo ( string | array $replyTo ) Sets the reply-to address of this message.
setSubject ( string $subject ) Sets the message subject.
setTextBody ( string $text ) Sets message plain text content.
setTo ( string | array $to ) Sets the message recipient(s).
toString ( ) : string Returns string representation of this message.

Method Details

attach() public méthode

Attaches existing file to the email message.
public attach ( string $fileName, array $options = [] )
$fileName string full file name
$options array options for embed file. Valid options are: - fileName: name, which should be used to attach file. - contentType: attached file MIME type.

attachContent() public méthode

Attach specified content as file for the email message.
public attachContent ( string $content, array $options = [] )
$content string attachment file content.
$options array options for embed file. Valid options are: - fileName: name, which should be used to attach file. - contentType: attached file MIME type.

embed() public méthode

This method should be used when embedding images or other data in a message.
public embed ( string $fileName, array $options = [] ) : string
$fileName string file name.
$options array options for embed file. Valid options are: - fileName: name, which should be used to attach file. - contentType: attached file MIME type.
Résultat string attachment CID.

embedContent() public méthode

This method should be used when embedding images or other data in a message.
public embedContent ( string $content, array $options = [] ) : string
$content string attachment file content.
$options array options for embed file. Valid options are: - fileName: name, which should be used to attach file. - contentType: attached file MIME type.
Résultat string attachment CID.

getBcc() public méthode

Returns the Bcc (hidden copy receiver) addresses of this message.
public getBcc ( ) : array
Résultat array the Bcc (hidden copy receiver) addresses of this message.

getCc() public méthode

Returns the Cc (additional copy receiver) addresses of this message.
public getCc ( ) : array
Résultat array the Cc (additional copy receiver) addresses of this message.

getCharset() public méthode

Returns the character set of this message.
public getCharset ( ) : string
Résultat string the character set of this message.

getFrom() public méthode

Returns the message sender.
public getFrom ( ) : string
Résultat string the sender

getReplyTo() public méthode

Returns the reply-to address of this message.
public getReplyTo ( ) : string
Résultat string the reply-to address of this message.

getSubject() public méthode

Returns the message subject.
public getSubject ( ) : string
Résultat string the message subject

getTo() public méthode

Returns the message recipient(s).
public getTo ( ) : array
Résultat array the message recipients

send() public méthode

Sends this email message.
public send ( yii\mail\MailerInterface $mailer = null ) : boolean
$mailer yii\mail\MailerInterface the mailer that should be used to send this message. If null, the "mail" application component will be used instead.
Résultat boolean whether this message is sent successfully.

setBcc() public méthode

Sets the Bcc (hidden copy receiver) addresses of this message.
public setBcc ( string | array $bcc )
$bcc string | array hidden copy receiver email address. You may pass an array of addresses if multiple recipients should receive this message. You may also specify receiver name in addition to email address using format: `[email => name]`.

setCc() public méthode

Sets the Cc (additional copy receiver) addresses of this message.
public setCc ( string | array $cc )
$cc string | array copy receiver email address. You may pass an array of addresses if multiple recipients should receive this message. You may also specify receiver name in addition to email address using format: `[email => name]`.

setCharset() public méthode

Sets the character set of this message.
public setCharset ( string $charset )
$charset string character set name.

setFrom() public méthode

Sets the message sender.
public setFrom ( string | array $from )
$from string | array sender email address. You may pass an array of addresses if this message is from multiple people. You may also specify sender name in addition to email address using format: `[email => name]`.

setHtmlBody() public méthode

Sets message HTML content.
public setHtmlBody ( string $html )
$html string message HTML content.

setReplyTo() public méthode

Sets the reply-to address of this message.
public setReplyTo ( string | array $replyTo )
$replyTo string | array the reply-to address. You may pass an array of addresses if this message should be replied to multiple people. You may also specify reply-to name in addition to email address using format: `[email => name]`.

setSubject() public méthode

Sets the message subject.
public setSubject ( string $subject )
$subject string message subject

setTextBody() public méthode

Sets message plain text content.
public setTextBody ( string $text )
$text string message plain text content.

setTo() public méthode

Sets the message recipient(s).
public setTo ( string | array $to )
$to string | array receiver email address. You may pass an array of addresses if multiple recipients should receive this message. You may also specify receiver name in addition to email address using format: `[email => name]`.

toString() public méthode

Returns string representation of this message.
public toString ( ) : string
Résultat string the string representation of this message.