PHP Class Helper\Mailer\Smtp

Inheritance: implements Contactable\IMailer
Show file Open project: sendya/shadowsocks-panel

Protected Properties

Property Type Description
$_address 发件人邮件地址
$_attachment 附件
$_bcc 秘密抄送
$_body 邮件正文
$_cc 抄送
$_errorMessage 错误信息
$_from 发件人
$_isSecurity 是否是安全连接
$_password 邮件传输代理密码
$_port 邮件传输代理服务器端口
$_sendServer 邮件传输代理服务器地址
$_socket socket资源
$_subject 主题
$_to 收件人
$_userName 邮件传输代理用户名

Public Methods

Method Description
__construct ( )
addAttachment ( string $file ) : boolean 设置邮件附件,多个附件,调用多次
error ( ) : string 返回错误信息
isAvailable ( )
send ( Mail $mail )
sendMail ( ) : boolean 发送邮件
setAddress ( $address )
setBcc ( string $bcc ) : boolean 设置秘密抄送,多个秘密抄送,调用多次
setCc ( string $cc ) : boolean 设置抄送,多个抄送,调用多次.
setFrom ( string $from ) : boolean 设置发件人
setMail ( string $subject, string $body ) : boolean 设置邮件信息
setReceiver ( string $to ) : boolean 设置收件人,多个收件人,调用多次.
setServer ( string $server, string $username = "", string $password = "", integer $port = 25, boolean $isSecurity = false ) : boolean 设置邮件传输代理,如果是可以匿名发送有邮件的服务器,只需传递代理服务器地址就行

Protected Methods

Method Description
close ( ) : boolean 关闭socket
closeSecutity ( ) : boolean 关闭安全socket
getCommand ( ) : array 返回mail命令
getMIMEType ( string $file ) : mixed 获取附件MIME类型
readFile ( string $file ) : mixed 读取附件文件内容,返回base64编码后的文件内容
sendCommand ( string $command, integer $code ) : boolean 发送命令
sendCommandSecurity ( string $command, integer $code ) : boolean 安全连接发送命令
socket ( ) : boolean 建立到服务器的网络连接
socketSecurity ( ) : boolean 建立到服务器的SSL网络连接

Method Details

__construct() public method

public __construct ( )

addAttachment() public method

设置邮件附件,多个附件,调用多次
public addAttachment ( string $file ) : boolean
$file string 文件地址
return boolean

close() protected method

关闭socket
protected close ( ) : boolean
return boolean

closeSecutity() protected method

关闭安全socket
protected closeSecutity ( ) : boolean
return boolean

error() public method

返回错误信息
public error ( ) : string
return string

getCommand() protected method

返回mail命令
protected getCommand ( ) : array
return array

getMIMEType() protected method

获取附件MIME类型
protected getMIMEType ( string $file ) : mixed
$file string 文件
return mixed

isAvailable() public method

public isAvailable ( )

readFile() protected method

读取附件文件内容,返回base64编码后的文件内容
protected readFile ( string $file ) : mixed
$file string 文件
return mixed

send() public method

public send ( Mail $mail )
$mail Model\Mail

sendCommand() protected method

发送命令
protected sendCommand ( string $command, integer $code ) : boolean
$command string 发送到服务器的smtp命令
$code integer 期望服务器返回的响应吗
return boolean

sendCommandSecurity() protected method

安全连接发送命令
protected sendCommandSecurity ( string $command, integer $code ) : boolean
$command string 发送到服务器的smtp命令
$code integer 期望服务器返回的响应吗
return boolean

sendMail() public method

发送邮件
public sendMail ( ) : boolean
return boolean

setAddress() public method

public setAddress ( $address )

setBcc() public method

设置秘密抄送,多个秘密抄送,调用多次
public setBcc ( string $bcc ) : boolean
$bcc string 秘密抄送地址
return boolean

setCc() public method

设置抄送,多个抄送,调用多次.
public setCc ( string $cc ) : boolean
$cc string 抄送地址
return boolean

setFrom() public method

设置发件人
public setFrom ( string $from ) : boolean
$from string 发件人地址
return boolean

setMail() public method

设置邮件信息
public setMail ( string $subject, string $body ) : boolean
$subject string 邮件主体内容,可以是纯文本,也可是是HTML文本
$body string 邮件主题
return boolean

setReceiver() public method

设置收件人,多个收件人,调用多次.
public setReceiver ( string $to ) : boolean
$to string 收件人地址
return boolean

setServer() public method

设置邮件传输代理,如果是可以匿名发送有邮件的服务器,只需传递代理服务器地址就行
public setServer ( string $server, string $username = "", string $password = "", integer $port = 25, boolean $isSecurity = false ) : boolean
$server string 代理服务器的ip或者域名
$username string 认证账号
$password string 认证密码
$port integer 代理服务器的端口,smtp默认25号端口
$isSecurity boolean 到服务器的连接是否为安全连接,默认false
return boolean

socket() protected method

建立到服务器的网络连接
protected socket ( ) : boolean
return boolean

socketSecurity() protected method

建立到服务器的SSL网络连接
protected socketSecurity ( ) : boolean
return boolean

Property Details

$_address protected property

发件人邮件地址
protected $_address

$_attachment protected property

附件
protected $_attachment

$_bcc protected property

秘密抄送
protected $_bcc

$_body protected property

邮件正文
protected $_body

$_cc protected property

抄送
protected $_cc

$_errorMessage protected property

错误信息
protected $_errorMessage

$_from protected property

发件人
protected $_from

$_isSecurity protected property

是否是安全连接
protected $_isSecurity

$_password protected property

邮件传输代理密码
protected $_password

$_port protected property

邮件传输代理服务器端口
protected $_port

$_sendServer protected property

邮件传输代理服务器地址
protected $_sendServer

$_socket protected property

socket资源
protected $_socket

$_subject protected property

主题
protected $_subject

$_to protected property

收件人
protected $_to

$_userName protected property

邮件传输代理用户名
protected $_userName