public abstract class EmailGateway

class.emailgateway.php #50

A base class for email gateways. All email-gateways should extend this class in order to work.


void __construct()

The constructor sets the _boundary_mixed and _boundary_alter variables to be unique hashes based off PHP's uniqid function.

void __destruct()

The destructor ensures that any open connections to the Email Gateway is closed.

boolean|mixed __get(string $name)

Gets a property.

Magic function, supplied by php. This function will attempt to find a variable set with $name and returns it. If the variable is not set, it will return false.

  • $name stringThe property name.

void|boolean __set(string $name, string $value)

Sets a property.

Magic function, supplied by php. This function will try and find a method of this class, by camelcasing the name, and appending it with set. If the function can not be found, an exception will be thrown.

  • $name stringThe property name.

  • $value stringThe property value;

void appendAttachment(string|array $file)

Appends one file attachment to the attachments array.

  • $file string|arrayCan be a string representing the file path, absolute or relative, i.e. '' or 'path/to/your/webspace/foo/bar.csv'. Can also be a keyed array. This will enable more options, like setting the charset used by mail agent to open the file or a different filename. Example: $email->appendAttachment(array( 'file' => '', 'filename' => 'bar.txt', 'charset' => 'UTF-8', 'mime-type' => 'text/csv', ));

void appendHeaderField(string $name, string $body)

Appends a single header field to the header fields array. The header field should be presented as a name/body pair.

  • $name stringThe header field name. Examples are From, Bcc, X-Sender and Reply-to.

  • $body stringThe header field body.

void appendHeaderFields(array $header_array)

Appends one or more header fields to the header fields array. Header fields should be presented as an array with name/body pairs.

  • $header_array arrayThe header fields. Examples are From, X-Sender and Reply-to.

boolean closeConnection()

Close the connection to the email Server. This function is used to allow persistent connections.

array contentInfoArray(string $type, string $file, string $filename, string $charset)

Builds the right content-type/encoding types based on file and content-type.

Will try to match a common description, based on the $type param. If nothing is found, will return a base64 attached file disposition.

Can be used to send to an email server directly.

  • $type stringoptional mime-type

  • $file stringoptional the path of the attachment

  • $filename stringoptional the name of the attached file

  • $charset stringoptional the charset of the attached file

XMLElement getPreferencesPane()

The preferences to add to the preferences pane in the admin area.

boolean openConnection()

Open new connection to the email server. This function is used to allow persistent connections.

boolean send()

Sends the actual email. This function should be implemented in the Email Gateway itself and should return true or false if the email was successfully sent. See the default gateway for an example.

void setAttachments(string|array $files)

This function sets one or multiple attachment files to the email.

Passing null to this function will erase the current values with an empty array.

  • $files string|arrayAccepts the same parameters format as EmailGateway::addAttachment() but you can also all multiple values at once if all files are wrap in a array. Example: $email->setAttachments(array( array( 'file' => '', 'charset' => 'UTF-8' ), 'path/to/your/webspace/foo/bar.csv', ... ));

boolean setConfiguration(array $config)

Sets all configuration entries from an array. This enables extensions like the ENM to create email settings panes that work regardless of the email gateway. Every gateway should extend this method to add their own settings.

void setFrom(string $email, string $name)

Sets the sender-email and sender-name.

  • $email stringThe email-address emails will be sent from.

  • $name stringThe name the emails will be sent from.

void setRecipients(string|array $email)

Sets the recipients.

  • $email string|arrayThe email-address(es) to send the email to.

void setReplyToEmailAddress(string $email)

Sets the reply-to-email.

  • $email stringThe email-address emails should be replied to.

void setReplyToName(string $name)

Sets the reply-to-name.

  • $name stringThe name emails should be replied to.

void setSenderEmailAddress(string $email)

Sets the sender-email.

  • $email stringThe email-address emails will be sent from.

void setSenderName(string $name)

Sets the sender-name.

  • $name stringThe name emails will be sent from.

void setSubject(string $subject)

Sets the subject.

  • $subject stringThe subject that the email will have.

void setTextEncoding(string $encoding)
  • $encoding stringMust be either quoted-printable or base64.

void setTextHtml(string $text_html)

This functions takes a string to be used as the HTML content for the Email

void setTextPlain(string $text_plain)

This functions takes a string to be used as the plaintext content for the Email

void setValidateAttachmentErrors(boolean $validate_attachment_errors)

Sets the property $_validate_attachment_errors

This property is true by default, so sending will break if any attachment can not be loaded; if it is false, attachment errors error will be ignored.

boolean validate()

Makes sure the Subject, Sender Email and Recipients values are all set and are valid. The message body is checked in prepareMessageBody

See Also

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details