PHP Класс luya\components\Mail

This component is registered on each LUYA instance, how to use: php if (Yii::$app->mail->compose('Subject', 'Message body of the Mail'->adress('[email protected]')->send()) { echo "Mail has been sent!"; } else { echo "Error" : Yii::$app->mail->error; } SMTP debug help: swaks -s HOST -p 587 -ehlo localhost -au AUTH_USER -to TO_ADRESSE -tls
Автор: Basil Suter ([email protected])
Наследование: extends yii\base\Component
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$altBody alternate text message if email client doesn't support HTML
$debug enable debug output mode 'Data and commands'
$from sender email address
$fromName sender name
$host email server host address
$isSMTP disable if you want to use old PHP sendmail
$layout Define a layout template file which is going to be wrapped around the setBody() content. The file alias will be resolved so an example layout could look as followed: php $layout = '@app/views/maillayout.php'; In your config or any mailer object. As in layouts the content of the mail specific html can be access in the $content variable. The example content of maillayout.php from above could look like this: php

My Company

$password email server password
$port email server port
$smtpSecure Posible values are tls or ssl
$username email server username

Открытые методы

Метод Описание
address ( string $email, string $name = null ) : Mail Add a single address with optional name
addresses ( array $emails ) : Mail Correct spelled alias method for adresses.
adresses ( array $emails ) : Mail Add multiple addresses into the mailer object.
bccAddress ( string $email, string $name = null ) : Mail Add a single BCC address with optional name
bccAddresses ( array $emails ) : Mail Add multiple BCC addresses into the mailer object.
ccAddress ( string $email, string $name = null ) : Mail Add a single CC address with optional name
ccAddresses ( array $emails ) : Mail Add multiple CC addresses into the mailer object.
cleanup ( ) : void Reset the mailer object to null
compose ( string $subject, string $body ) : Mail Compose a new mail message, this will first flush existing mailer objects
getError ( ) : string Get the mailer error info if any.
getMailer ( ) : PHPMailer Getter for the mailer object
send ( ) : boolean Trigger the send event of the mailer
setBody ( string $body ) : Mail Set the HTML body for the mailer message, if a layout is defined the layout will automatically wrapped about the html body.
setSubject ( string $subject ) : Mail Set the mail message subject of the mailer instance
smtpTest ( $verbose )

Защищенные методы

Метод Описание
wrapLayout ( string $content ) Wrap the layout from the $layout propertie and store the passed content as $content variable in the view.

Описание методов

address() публичный Метод

Add a single address with optional name
public address ( string $email, string $name = null ) : Mail
$email string The email address e.g. [email protected]
$name string The name for the address e.g. John Doe
Результат Mail

addresses() публичный Метод

Correct spelled alias method for adresses.
public addresses ( array $emails ) : Mail
$emails array
Результат Mail

adresses() публичный Метод

If no key is used, the name is going to be ignored, if a string key is available it represents the name. php adresses(['[email protected]', '[email protected]']); or with names php adresses(['John Doe' => '[email protected]', 'Jane Doe' => '[email protected]']);
С версии: 1.0.0-beta4
public adresses ( array $emails ) : Mail
$emails array An array with email adresses or name => email paring to use names.
Результат Mail

bccAddress() публичный Метод

Add a single BCC address with optional name
public bccAddress ( string $email, string $name = null ) : Mail
$email string The email address e.g. [email protected]
$name string The name for the address e.g. John Doe
Результат Mail

bccAddresses() публичный Метод

If no key is used, the name is going to be ignored, if a string key is available it represents the name. php bccAddresses(['[email protected]', '[email protected]']); or with names php bccAddresses(['John Doe' => '[email protected]', 'Jane Doe' => '[email protected]']);
С версии: 1.0.0-RC2
public bccAddresses ( array $emails ) : Mail
$emails array An array with email addresses or name => email paring to use names.
Результат Mail

ccAddress() публичный Метод

Add a single CC address with optional name
public ccAddress ( string $email, string $name = null ) : Mail
$email string The email address e.g. [email protected]
$name string The name for the address e.g. John Doe
Результат Mail

ccAddresses() публичный Метод

If no key is used, the name is going to be ignored, if a string key is available it represents the name. php ccAddresses(['[email protected]', '[email protected]']); or with names php ccAddresses(['John Doe' => '[email protected]', 'Jane Doe' => '[email protected]']);
С версии: 1.0.0-RC2
public ccAddresses ( array $emails ) : Mail
$emails array An array with email addresses or name => email paring to use names.
Результат Mail

cleanup() публичный Метод

Reset the mailer object to null
public cleanup ( ) : void
Результат void

compose() публичный Метод

Compose a new mail message, this will first flush existing mailer objects
public compose ( string $subject, string $body ) : Mail
$subject string The subject of the mail
$body string The HTML body of the mail message.
Результат Mail

getError() публичный Метод

Get the mailer error info if any.
public getError ( ) : string
Результат string

getMailer() публичный Метод

Getter for the mailer object
public getMailer ( ) : PHPMailer
Результат PHPMailer

send() публичный Метод

Trigger the send event of the mailer
public send ( ) : boolean
Результат boolean

setBody() публичный Метод

Set the HTML body for the mailer message, if a layout is defined the layout will automatically wrapped about the html body.
public setBody ( string $body ) : Mail
$body string The HTML body message
Результат Mail

setSubject() публичный Метод

Set the mail message subject of the mailer instance
public setSubject ( string $subject ) : Mail
$subject string The subject message
Результат Mail

smtpTest() публичный Метод

См. также: https://github.com/PHPMailer/PHPMailer/blob/master/examples/smtp_check.phps
public smtpTest ( $verbose )

wrapLayout() защищенный Метод

Wrap the layout from the $layout propertie and store the passed content as $content variable in the view.
protected wrapLayout ( string $content )
$content string The content to wrapp inside the layout.

Описание свойств

$altBody публичное свойство

alternate text message if email client doesn't support HTML
public $altBody

$debug публичное свойство

enable debug output mode 'Data and commands'
public $debug

$from публичное свойство

sender email address
public $from

$fromName публичное свойство

sender name
public $fromName

$host публичное свойство

email server host address
public $host

$isSMTP публичное свойство

disable if you want to use old PHP sendmail
public $isSMTP

$layout публичное свойство

Define a layout template file which is going to be wrapped around the setBody() content. The file alias will be resolved so an example layout could look as followed: php $layout = '@app/views/maillayout.php'; In your config or any mailer object. As in layouts the content of the mail specific html can be access in the $content variable. The example content of maillayout.php from above could look like this: php

My Company

С версии: 1.0.0-beta7
public $layout

$password публичное свойство

email server password
public $password

$port публичное свойство

email server port
public $port

$smtpSecure публичное свойство

Posible values are tls or ssl
public $smtpSecure

$username публичное свойство

email server username
public $username