public class SMTP

class.smtp.php #22

A SMTP client class, for sending text/plain emails. This class only supports the very basic SMTP functions. Inspired by the SMTP class in the Zend library

Constants

public static
class.smtp.php #24
static int TIMEOUT = 30

Methods

\SMTP __construct(string $host, integer $port, array $options)

Constructor.

Parameters
  • $host stringHost to connect to. Defaults to localhost (127.0.0.1)

  • $port integerWhen ssl is used, defaults to 465 When no ssl is used, and ini_get returns no value, defaults to 25.

  • $options arrayCurrently supports 3 values: $options['secure'] can be ssl, tls or null. $options['username'] the username used to login to the server. Leave empty for no authentication. $options['password'] the password used to login to the server. Leave empty for no authentication. $options['local_ip'] the ip address used in the ehlo/helo commands. Only ip's are accepted.

boolean checkConnection()

Checks to see if $this->_connection is a valid resource. Throws an exception if there is no connection, otherwise returns true.

void data(string $data)

Calls the data command on the server. Also includes header fields in the command.

void helo()

Initiates the ehlo/helo requests.

void mail(string $from)

Calls the MAIL command on the server.

Parameters
  • $from stringThe email address to send the email from.

void quit()

Disconnects to the server.

void rcpt(string $to)

Calls the RCPT command on the server. May be called multiple times for more than one recipient.

Parameters
  • $to stringThe address to send the email to.

void rset()

Resets the current session. This 'undoes' all rcpt, mail, etc calls.

boolean sendMail(string $from, string $to, string $subject, string $message)

The actual email sending. The connection to the server (connecting, EHLO, AUTH, etc) is done here, right before the actual email is sent. This is to make sure the connection does not time out.

Parameters
  • $from stringThe from string. Should have the following format: email@domain.tld

  • $to stringThe email address to send the email to.

  • $subject stringThe subject to send the email to.

void setHeader(string $header, string $value)

Sets a header to be sent in the email.

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