Yioop_V9.5_Source_Code_Documentation

MailServer
in package
implements MediaConstants

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);

Tags
author

Chris Pollett

Interfaces, Classes, Traits and Enums

MediaConstants
Shared constants and enums used by components that are involved in the media related operations

Table of Contents

CONT_REQ  = 334
Send next authentication item
EOL  = "\r\n"
End of line string for an SMTP server
GO_AHEAD  = 235
authentication successful
OKAY  = 250
SMTP last action okay
SERVER_READY  = 220
Service ready for requests
SMTP_CODE_LEN  = 3
Length of an SMTP response code
SMTP_TIMEOUT  = 10
How long before timeout when making a connection to an SMTP server
START_INPUT  = 354
Ready for the actual mail input
$connection  : resource
Used for socket connection to SMTP server
$login  : string
If auth is used, the username to log into the SMTP server with
$messages  : array<string|int, mixed>
Used to store response messages received from SMTP server
$password  : string
If auth is used, the password to log into the SMTP server with
$port  : int
Port number the mail server is running on
$secure  : mixed
Either false if no security/auth used or ssl or tls
$sender_email  : string
Email address of default mail sender
$sender_host  : string
Hostname of default mail sender
$server  : string
Domain name of the SMTP server
__construct()  : mixed
Encapsulates the domain and credentials of a SMTP server in a MailServer object
endSession()  : mixed
Closes the currently active SMTP session
readResponseGetCode()  : string
Reads data from an SMTP server until a command response code detected
send()  : mixed
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)
sendImmediate()  : mixed
Sends immediately an email (as opposed to queueing for a future process to send)
sendQueue()  : mixed
Sends an email to the media updater mail queue
smtpCommand()  : string
Sends a single SMTP command to the current SMTP server and then returns the SMTP response code
startSession()  : bool
Connects to and if needs be authenticates with a SMTP server

Constants

CONT_REQ

Send next authentication item

public mixed CONT_REQ = 334

EOL

End of line string for an SMTP server

public mixed EOL = "\r\n"

GO_AHEAD

authentication successful

public mixed GO_AHEAD = 235

OKAY

SMTP last action okay

public mixed OKAY = 250

SERVER_READY

Service ready for requests

public mixed SERVER_READY = 220

SMTP_CODE_LEN

Length of an SMTP response code

public mixed SMTP_CODE_LEN = 3

SMTP_TIMEOUT

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

public mixed SMTP_TIMEOUT = 10

START_INPUT

Ready for the actual mail input

public mixed START_INPUT = 354

Properties

$connection

Used for socket connection to SMTP server

public resource $connection

$login

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

public string $login

$messages

Used to store response messages received from SMTP server

public array<string|int, mixed> $messages

$password

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

public string $password

$port

Port number the mail server is running on

public int $port

$secure

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

public mixed $secure

$sender_email

Email address of default mail sender

public string $sender_email

$sender_host

Hostname of default mail sender

public string $sender_host

$server

Domain name of the SMTP server

public string $server

Methods

__construct()

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

public __construct(string $sender_email, string $server, int $port, string $login, string $password[, mixed $secure = false ]) : mixed
Parameters
$sender_email : string

who mail will be sent from (can be overwritten)

$server : string

domain name of machine will connect to

$port : int

port on that machine

$login : string

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

$password : string

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

$secure : mixed = false

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

Return values
mixed

endSession()

Closes the currently active SMTP session

public endSession() : mixed
Return values
mixed

readResponseGetCode()

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

public readResponseGetCode() : string
Return values
string

three byte response code

send()

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)

public send(string $subject, string $from, string $to, string $message) : mixed
Parameters
$subject : string

subject line of the email

$from : string

sender email address

$to : string

recipient email address

$message : string

message body for the email

Return values
mixed

sendImmediate()

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

public sendImmediate(string $subject, string $from, string $to, string $message) : mixed
Parameters
$subject : string

subject line of the email

$from : string

sender email address

$to : string

recipient email address

$message : string

message body for the email

Return values
mixed

sendQueue()

Sends an email to the media updater mail queue

public sendQueue(string $subject, string $from, string $to, string $message) : mixed
Parameters
$subject : string

subject line of the email

$from : string

sender email address

$to : string

recipient email address

$message : string

message body for the email

Return values
mixed

smtpCommand()

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

public smtpCommand(string $command) : string
Parameters
$command : string

the command to execute

Return values
string

three character integer response code

startSession()

Connects to and if needs be authenticates with a SMTP server

public startSession() : bool
Return values
bool

whether the session was successfully established


        

Search results