\seekquarry\yioop\libraryMailServer

A small class for communicating with an SMTP server. Used to avoid configuration issues that might be needed with PHP's built-in mail() function. Here is an example of how one might use this class:

$server = new MailServer('somewhere.com', 587, 'someone', 'pword', 'tls'); $to = "cool@place.com"; $from = "someone@somewhere.com"; $subject = "Test Mail"; $message = "This is a test"; $server->send($subject, $from, $to, $message);

Summary

Methods
Properties
Constants
__construct()
startSession()
endSession()
readResponseGetCode()
smtpCommand()
send()
sendImmediate()
sendQueue()
$sender_email
$sender_host
$server
$port
$login
$password
$secure
EOL
SMTP_TIMEOUT
SMTP_CODE_LEN
SERVER_READY
OKAY
GO_AHEAD
CONT_REQ
START_INPUT
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

EOL

EOL

End of line string for an SMTP server

SMTP_TIMEOUT

SMTP_TIMEOUT

How long before timeout when making a connection to an SMTP server

SMTP_CODE_LEN

SMTP_CODE_LEN

Length of an SMTP response code

SERVER_READY

SERVER_READY

Service ready for requests

OKAY

OKAY

SMTP last action okay

GO_AHEAD

GO_AHEAD

authentication successful

CONT_REQ

CONT_REQ

Send next authentication item

START_INPUT

START_INPUT

Ready for the actual mail input

Properties

$sender_email

$sender_email : string

Email address of default mail sender

Type

string

$sender_host

$sender_host : string

Hostname of default mail sender

Type

string

$server

$server : string

Domain name of the SMTP server

Type

string

$port

$port : integer

Port number the mail server is running on

Type

integer

$login

$login : string

If auth is used, the username to log into the SMTP server with

Type

string

$password

$password : string

If auth is used, the password to log into the SMTP server with

Type

string

$secure

$secure : mixed

Either false if no security/auth used or ssl or tls

Type

mixed

Methods

__construct()

__construct(string  $sender_email, string  $server, integer  $port, string  $login, string  $password, mixed  $secure = false) 

Encapuslates the domain and credentials of a SMTP server in a MailServer object

Parameters

string $sender_email

who mail will be sent from (can be overwritten)

string $server

domain name of machine will connect to

integer $port

port on that machine

string $login

username to use for authentication ("" if no auth)

string $password

password to use for authentication ("" if no auth)

mixed $secure

false is SSL and TLS not used, otherwise SSL or TLS

startSession()

startSession() : boolean

Connects to and if needs be authenticates with a SMTP server

Returns

boolean —

whether the session was successfully established

endSession()

endSession() 

Closes the currently active SMTP session

readResponseGetCode()

readResponseGetCode() : string

Reads data from an SMTP server until a command response code detected

Returns

string —

three byte response code

smtpCommand()

smtpCommand(string  $command) : string

Sends a single SMTP command to the current SMTP server and then returns the SMTP response code

Parameters

string $command

the command to execute

Returns

string —

three character integer response code

send()

send(string  $subject, string  $from, string  $to, string  $message) 

Sends (or queues for media updater) an email (much like PHP's mail command, but not requiring a configured smtp server on the current machine)

Parameters

string $subject

subject line of the email

string $from

sender email address

string $to

recipient email address

string $message

message body for the email

sendImmediate()

sendImmediate(string  $subject, string  $from, string  $to, string  $message) 

Sends immediately an email (as opposed to queueing for a future process to send)

Parameters

string $subject

subject line of the email

string $from

sender email address

string $to

recipient email address

string $message

message body for the email

sendQueue()

sendQueue(string  $subject, string  $from, string  $to, string  $message) 

Sends an email to the media updater mail queue

Parameters

string $subject

subject line of the email

string $from

sender email address

string $to

recipient email address

string $message

message body for the email