The OpenD Programming Language

SMTP

Basic SMTP protocol support.

struct SMTP {}

Members

Aliases

CurlProxy
alias CurlProxy = etc.c.curl.CurlProxy

Type of proxy

requestAbort
alias requestAbort = CurlReadFunc.abort

Value to return from onSend delegate in order to abort a request

requestPause
alias requestPause = CurlReadFunc.pause

Value to return from onSend/onReceive delegates in order to pause a request

Functions

mailTo
void mailTo(const(char)[][] recipients)

Setter for the recipient email addresses.

perform
CurlCode perform(ThrowOnError throwOnError)

Performs the request as configured.

setAuthentication
void setAuthentication(const(char)[] username, const(char)[] password, const(char)[] domain)

Set the user name, password and optionally domain for authentication purposes.

setProxyAuthentication
void setProxyAuthentication(const(char)[] username, const(char)[] password)

Set the user name and password for proxy authentication.

shutdown
void shutdown()

Stop and invalidate this instance.

Properties

connectTimeout
Duration connectTimeout [@property setter]

Set timeout for connecting.

dataTimeout
Duration dataTimeout [@property setter]

Set timeout for activity on connection.

dnsTimeout
Duration dnsTimeout [@property setter]

DNS lookup timeout.

isStopped
bool isStopped [@property getter]

True if the instance is stopped. A stopped instance is not usable.

localPort
ushort localPort [@property setter]

Set the local outgoing port to use.

localPortRange
ushort localPortRange [@property setter]

Set the local outgoing port range to use. This can be used together with the localPort property.

mailFrom
const(char)[] mailFrom [@property setter]

Setter for the sender's email address.

message
string message [@property setter]

Sets the message body text.

netInterface
const(char)[] netInterface [@property setter]
const(ubyte)[4] netInterface [@property setter]
InternetAddress netInterface [@property setter]

The network interface to use in form of the IP of the interface.

onProgress
int delegate(size_t dlTotal, size_t dlNow, size_t ulTotal, size_t ulNow) onProgress [@property setter]

The event handler that gets called to inform of upload/download progress.

onReceive
size_t delegate(ubyte[]) onReceive [@property setter]

The event handler that receives incoming data. Be sure to copy the incoming ubyte[] since it is not guaranteed to be valid after the callback returns.

onSend
size_t delegate(void[]) onSend [@property setter]

The event handler that gets called when data is needed for sending. The length of the void[] specifies the maximum number of bytes that can be sent.

operationTimeout
Duration operationTimeout [@property setter]

Set maximum time an operation is allowed to take. This includes dns resolution, connecting, data transfer, etc.

proxy
const(char)[] proxy [@property setter]

Proxy See: _proxy

proxyPort
ushort proxyPort [@property setter]

Proxy port See: _proxy_port

proxyType
CurlProxy proxyType [@property setter]

Proxy type See: _proxy_type

tcpNoDelay
bool tcpNoDelay [@property setter]

Set the tcp no-delay socket option on or off. See: nodelay

url
const(char)[] url [@property setter]

The URL to specify the location of the resource.

verbose
bool verbose [@property setter]

Set verbose. This will print request information to stderr.

Static functions

opCall
SMTP opCall(const(char)[] url)

Sets to the URL of the SMTP server.

opCall
SMTP opCall()

Mixed In Members

From mixin Protocol

requestPause
alias requestPause = CurlReadFunc.pause

Value to return from onSend/onReceive delegates in order to pause a request

requestAbort
alias requestAbort = CurlReadFunc.abort

Value to return from onSend delegate in order to abort a request

handle
Curl handle [@property getter]

The curl handle used by this connection.

isStopped
bool isStopped [@property getter]

True if the instance is stopped. A stopped instance is not usable.

shutdown
void shutdown()

Stop and invalidate this instance.

verbose
bool verbose [@property setter]

Set verbose. This will print request information to stderr.

dataTimeout
Duration dataTimeout [@property setter]

Set timeout for activity on connection.

operationTimeout
Duration operationTimeout [@property setter]

Set maximum time an operation is allowed to take. This includes dns resolution, connecting, data transfer, etc.

connectTimeout
Duration connectTimeout [@property setter]

Set timeout for connecting.

proxy
const(char)[] proxy [@property setter]

Proxy See: _proxy

proxyPort
ushort proxyPort [@property setter]

Proxy port See: _proxy_port

CurlProxy
alias CurlProxy = RawCurlProxy

Type of proxy

proxyType
CurlProxy proxyType [@property setter]

Proxy type See: _proxy_type

dnsTimeout
Duration dnsTimeout [@property setter]

DNS lookup timeout.

netInterface
const(char)[] netInterface [@property setter]
const(ubyte)[4] netInterface [@property setter]
InternetAddress netInterface [@property setter]

The network interface to use in form of the IP of the interface.

localPort
ushort localPort [@property setter]

Set the local outgoing port to use.

setNoProxy
void setNoProxy(string hosts)

Set the no proxy flag for the specified host names.

localPortRange
ushort localPortRange [@property setter]

Set the local outgoing port range to use. This can be used together with the localPort property.

tcpNoDelay
bool tcpNoDelay [@property setter]

Set the tcp no-delay socket option on or off. See: nodelay

verifyPeer
bool verifyPeer [@property setter]

Sets whether SSL peer certificates should be verified. See: verifypeer

verifyHost
bool verifyHost [@property setter]

Sets whether the host within an SSL certificate should be verified. See: verifypeer

setAuthentication
void setAuthentication(const(char)[] username, const(char)[] password, const(char)[] domain)

Set the user name, password and optionally domain for authentication purposes.

setProxyAuthentication
void setProxyAuthentication(const(char)[] username, const(char)[] password)

Set the user name and password for proxy authentication.

onSend
size_t delegate(void[]) onSend [@property setter]

The event handler that gets called when data is needed for sending. The length of the void[] specifies the maximum number of bytes that can be sent.

onReceive
size_t delegate(ubyte[]) onReceive [@property setter]

The event handler that receives incoming data. Be sure to copy the incoming ubyte[] since it is not guaranteed to be valid after the callback returns.

onProgress
int delegate(size_t dlTotal, size_t dlNow, size_t ulTotal, size_t ulNow) onProgress [@property setter]

The event handler that gets called to inform of upload/download progress.

Examples

import std.net.curl;

// Send an email with SMTPS
auto smtp = SMTP("smtps://smtp.gmail.com");
smtp.setAuthentication("from.addr@gmail.com", "password");
smtp.mailTo = ["<to.addr@gmail.com>"];
smtp.mailFrom = "<from.addr@gmail.com>";
smtp.message = "Example Message";
smtp.perform();

See Also

Meta