Constructor
EasySwift
__construct
( $connection, [string $domain = null])
-
Swift_Connection
$connection: The connection to use
-
string
$domain: The domain name of this server (not the SMTP server)
Add a new attachment to the message
boolean
addAttachment
(mixed $data, [string $filename = null], [string $type = "application/octet-stream"], [string $encoding = null])
-
mixed
$data: The attachment to add. If this is a string it's used as the file contents. If it's an instance of Swift_Message_Attachment it's used as the entire part. If it's an instance of Swift_File it's used as the contents.
-
string
$filename: Filename, optional
-
string
$type: Content-type. Default application/octet-stream
-
string
$encoding: The encoding used (default is base64)
Add Bcc: recipients to the email
boolean
addBcc
(mixed $address)
-
mixed
$address: Bcc address(es)
Add Cc: recipients to the email
boolean
addCc
(mixed $address)
-
mixed
$address: Cc address(es)
Add headers to the message
void
addHeaders
(string $string)
-
string
$string: The message headers to append, separated by CRLF
Embed an image into the message and get the src attribute for HTML
Returns FALSE on failure
string
addImage
(mixed $input)
-
mixed
$input: The path to the image, a Swift_Message_Image object or a Swift_File object
Add a new MIME part to the message
void
addPart
(mixed $body, [string $type = "text/plain"], [string $encoding = null], [string $charset = null])
-
mixed
$body: The part to add. If this is a string it's used as the body. If it's an instance of Swift_Message_Part it's used as the entire part
-
string
$type: Content-type, default text/plain
-
string
$encoding: The encoding used (default is to let Swift decide)
-
string
$charset: The charset to use (default is to let swift decide)
Add recipients to the email
boolean
addRecipients
(mixed $address, string $type)
-
mixed
$address: Address(es)
-
string
$type: Recipient type (To, Cc, Bcc)
Add To: recipients to the email
boolean
addTo
(mixed $address)
-
mixed
$address: To address(es)
Authenticate with SMTP authentication
boolean
authenticate
(string $username, string $password)
-
string
$username: The SMTP username
-
string
$password: The SMTP password
Turn automatic flsuhing on or off.
This in ON by deault. It removes the message and all parts after sending.
void
autoFlush
([boolean $flush = true])
Close the connection to the MTA
boolean
close
()
Send a command to Swift and get a response
string
command
(string $command)
-
string
$command: The command to send (leave of CRLF)
Connect to the MTA if not already connected
void
connect
()
Dump the contents of the log to the browser The log contains some < and > characters so you may need to view source Note that this method dumps data to the browser, it does NOT return anything.
void
dumpLog
()
Embed an inline file into the message, such as a Image or MIDI file
string
embedFile
(mixed $data, [string $type = "application/octet-stream"], [string $filename = null], [string $cid = null])
-
mixed
$data: The file contents, Swift_File object or Swift_Message_EmbeddedFile object
-
string
$type: The content-type of the file, optional
-
string
$filename: The filename to use, optional
-
string
$cid: the Content-ID to use, optional
Flush message, recipients and headers
void
flush
()
Clear out all attachments
boolean
flushAttachments
()
Clear out all Bcc: recipients
void
flushBcc
()
Clear out all Cc: recipients
void
flushCc
()
Clear the current list of errors
void
flushErrors
()
Clear out all message headers
void
flushHeaders
()
Clear out all message parts
boolean
flushParts
()
Clear out all To: recipients
void
flushTo
()
Get an array of Bcc addresses
This currently returns an array of Swift_Address objects and may be simplified to an array of strings in later versions
array
getBccAddresses
()
Get an array of Cc addresses
This currently returns an array of Swift_Address objects and may be simplified to an array of strings in later versions
array
getCcAddresses
()
Get the charset of the charset to use in the message
string
getCharset
()
Get the full list of errors
array
getErrors
()
Get a list of any addresses which have failed since instantiation
array
getFailedRecipients
()
Get the last error that occured
string
getLastError
()
Get the currently set MIME warning (seen by old clients)
string
getMimeWarning
()
Get a reference to the plugin identified by $name
Swift_Events_Listener
getPlugin
(string $name)
-
string
$name: the ID of the plugin
Get the reply-to address(es) as an array of strings
array
getReplyTo
()
Get the return-path address as a string
string
getReturnPath
()
Get an array of To addresses
This currently returns an array of Swift_Address objects and may be simplified to an array of strings in later versions
array
getToAddresses
()
Dump the log contents
void
getTransactions
()
Perform the SMTP greeting process (don't do this unless you understand why you're doing it)
void
handshake
()
Check if Swift has failed or not
This facade stops processing if so
boolean
hasFailed
()
Check if the current connection is open or not
boolean
isConnected
()
Load in a new authentication mechanism for SMTP
This needn't be called since Swift will locate any available in Swift/Authenticator/*.php
void
loadAuthenticator
( $auth)
-
Swift_Authenticator
$auth: The authentication mechanism to load
Add a new plugin to respond to events
string
loadPlugin
( $plugin, [string $name = null])
-
Swift_Events_Listener
$plugin: The plugin to load
-
string
$name: The ID to identify the plugin by if needed
Reset the current message and start a fresh one
void
newMessage
([ $msg = false])
Reset the current list of recipients and start a new one
void
newRecipientList
([ $list = false])
Remove the plugin identified by $name
boolean
removePlugin
(string $name)
-
string
$name: The ID of the plugin
Request for a read recipient to be sent to the reply-to address
void
requestReadReceipt
([boolean $request = true])
Send an email to a number of recipients
Returns the number of successful recipients, or FALSE on failure
int
send
(mixed $recipients, mixed $from, string $subject, [string $body = null])
-
mixed
$recipients: The recipients to send to. One of string, array, 2-dimensional array or Swift_Address
-
mixed
$from: The address to send from. string or Swift_Address
-
string
$subject: The message subject
-
string
$body: The message body, optional
Set the charset of the charset to use in the message
boolean
setCharset
(string $charset)
-
string
$charset: The charset (e.g. utf-8, iso-8859-1 etc)
Set an error message
void
setError
(string $msg)
-
string
$msg: Error message
Set a header in the message
void
setHeader
(string $name, string $value)
-
string
$name: The name of the header
-
string
$value: The value of the header (without attributes)
Set an attribute in the message headers
For example charset in Content-Type: text/html; charset=utf-8 set by $swift->setHeaderAttribute("Content-Type", "charset", "utf-8")
void
setHeaderAttribute
(string $name, string $attribute, string $value)
-
string
$name: The name of the header
-
string
$attribute: The name of the attribute
-
string
$value: The value of the attribute
Set the encoding used in the message header
The encoding can be one of Q (quoted-printable) or B (base64)
void
setHeaderEncoding
([string $mode = "B"])
-
string
$mode: The encoding to use
Set the maximum size of the log
void
setMaxLogSize
(int $size)
Set the multipart MIME warning message (only seen by old clients)
void
setMimeWarning
(string $text)
-
string
$text: The message to show
Set the message priority
This is an integer between 1 (high) and 5 (low)
void
setPriority
(int $priority)
-
int
$priority: The level of priority to use
Set the reply-to header
void
setReplyTo
(mixed $address)
-
mixed
$address: The address replies come to. String, or Swift_Address, or an array of either.
Set the return path address (where bounces go to)
void
setReturnPath
(mixed $address)
-
mixed
$address: The address as a string or Swift_Address
Turn a string representation of an email address into a Swift_Address object
Enable line resizing (on 1000 by default)
void
useAutoLineResizing
([int $size = 1000])
-
int
$size: The number of characters allowed on a line
This method should be called if you do not wish to send messages in batch mode (i.e. if all recipients should see each others' addresses)
void
useExactCopy
([boolean $bool = true])
-
boolean
$bool: If this mode should be used
Turn logging on or off (saves memory)
void
useLogging
([boolean $use = true])