1 # SMTP Transport Options
3 This document details the various options available to the
4 `Zend\Mail\Transport\Smtp` mail transport.
8 ### Basic SMTP Transport Usage
11 use Zend\Mail\Transport\Smtp as SmtpTransport;
12 use Zend\Mail\Transport\SmtpOptions;
14 // Setup SMTP transport
15 $transport = new SmtpTransport();
16 $options = new SmtpOptions([
17 'name' => 'localhost.localdomain',
18 'host' => '127.0.0.1',
21 $transport->setOptions($options);
24 If you require authentication, see the section on [SMTP authentication](smtp-authentication.md#examples)
25 for examples of configuring authentication credentials.
27 ## Configuration Options
29 Option name | Description
30 ------------------- | -----------
31 `name` | Name of the SMTP host; defaults to "localhost".
32 `host` | Remote hostname or IP address; defaults to "127.0.0.1".
33 `port` | Port on which the remote host is listening; defaults to "25".
34 `connection_class` | Fully-qualified classname or short name resolvable via `Zend\Mail\Protocol\SmtpPluginManager`. See the [SMTP authentication](smtp-authentication.md#connection_class) documentation for details.
35 `connection_config` | Optional associative array of parameters to pass to the connection class in order to configure it. By default, this is empty. See the [SMTP authentication](smtp-authentication.md#connection_config) documentation for details.
45 Returns the string name of the local client hostname.
50 setName(string $name) : void
53 Set the string name of the local client hostname.
55 ### getConnectionClass
58 getConnectionClass() : string
61 Returns a string indicating the connection class name to use.
63 ### setConnectionClass
66 setConnectionClass(string $connectionClass) : void
69 Set the connection class to use.
71 ### getConnectionConfig
74 getConnectionConfig() : array
77 Get configuration for the connection class.
79 ### setConnectionConfig
82 setConnectionConfig(array $config) : void
85 Set configuration for the connection class. Typically, if using anything other
86 than the default connection class, this will be an associative array with the
87 keys "username" and "password".
95 Returns a string indicating the IP address or host name of the SMTP server via
96 which to send messages.
101 setHost(string $host) : void
104 Set the SMTP host name or IP address.
112 Retrieve the integer port on which the SMTP host is listening.
117 setPort(int $port) : void
120 Set the port on which the SMTP host is listening.
125 __construct(null|array|Traversable $config) : void
128 Instantiate the class, and optionally configure it with values provided.