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
파일 보기 프로젝트 열기: luyadev/luya 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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