Chilkat.MailMan PHP Reference

Chilkat.MailMan

The Chilkat MailMan class is reponsible for sending email though SMTP and receiving/managing email on POP3 servers.

Object Creation

$obj = new COM("Chilkat.MailMan");

Properties

bool AllOrNone

Prevents sending any email if any of the addresses in the recipient list are rejected by the SMTP server. The default value is false, which indicates that the mail sending should continue even if some email addresses are invalid. (Note: Not all SMTP servers check the validity of email addresses, and even for those that do, it is not 100% accurate.)

Note: An SMTP server only knows the validity of email addresses within the domain it controls.

bool AutoGenMessageId

Controls whether a unique Message-ID header is auto-generated for each email sent.

The Message-ID header field should contain a unique message ID for each email that is sent. The default behavior is to auto-generate this header field at the time the message is sent. This makes it easier for the same email object to be re-used. If the message ID is not unique, the SMTP server may consider the message to be a duplicate of one that has already been sent, and may discard it without sending. This property controls whether message IDs are automatically generated. If auto-generation is turned on (true), the value returned by GetHeaderField("Message-ID") will not reflect the actual message ID that gets sent with the email.

To turn off automatic Message-ID generation, set this property to false.

bool AutoSaveCerts

Controls whether certificates found in incoming signed emails are automatically saved to the "Chilkat" certificate store. The default is false. The Chilkat cert store is located in the registry in HKEY_LOCAL_MACHINE/Software/Chilkat/SystemCertificates.

bool AutoUnwrapSecurity

When an email is downloaded from a POP3 server or loaded from a .eml file, it is automatically "unwrapped" if the email is signed and/or encrypted. The results of the digital signature verification and decryption can be accessed with the following email object properties and methods: EncryptedBy, SignedBy, ReceivedEncrypted, ReceivedSigned, GetEncryptedByCert, and GetSignedByCert.

To auto-unwrap, set this property equal to true (the default). Otherwise set it to false.

string ClientIpAddress

The IP address to use for computers with multiple network interfaces or IP addresses. For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.

int ConnectTimeout

The time (in seconds) to wait before while trying to connect to a mail server (POP3 or SMTP). The default value is 30.

string DsnEnvid

(An SMTP DSN service extension feature) An arbitrary string that will be used as the ENVID property when sending email. See RFC 3461 for more details.

string DsnNotify

(An SMTP DSN service extension feature) A string that will be used as the NOTIFY parameter when sending email. (See RFC 3461 for more details. ) This string can be left blank, or can be set to "NEVER", or any combination of a comma-separated list of "SUCCESS", "FAILURE", or "NOTIFY".

string DsnRet

(An SMTP DSN service extension feature) A string that will be used as the RET parameter when sending email. (See RFC 3461 for more details. ) This string can be left blank, or can be set to "FULL" to receive entire-message DSN notifications, or "HDRS" to receive header-only DSN notifications.

bool EmbedCertChain

If true, causes the digital certificate chain to be embedded in signed emails. The certificates in the chain of authentication are embedded up to but not including the root certificate. If the IncludeRootCert property is also true, then the root CA certificate is also included in the S/MIME signature.

string Filter

An expression that is applied to any of the following method calls when present: LoadXmlFile, LoadXmlString, LoadMbx, CopyMail, and TransferMail. For these methods, only the emails that match the filter's expression are returned in the email bundle. In the case of TransferMail, only the matching emails are removed from the mail server. The filter allows any header field, or the body, to be checked.

Here are some examples of expressions:

Body like "mortgage rates*". 
Subject contains "update" and From contains "chilkat" 
To = "info@chilkatsoft.com" 

Here are the general rules for forming filter expressions:

Any MIME header field name can be used, case is insensitive. 
Literal strings are double-quoted, and case is insensitive. 
The "*" wildcard matches 0 or more occurances of any character. 
Parentheses can be used to control precedence. 
The logical operators are: AND, OR, NOT (case insensitive) 
Comparison operators are: =, <, >, <=, >=, <> 
String comparison operators are: CONTAINS, LIKE (case insensitive)

More information about the Filter property (for POP3)

int HeartbeatMs

The time interval, in milliseconds, between AbortCheck event callbacks. The heartbeat provides a means for an application to monitor a mail-sending and/or mail-reading method call, and to abort it while in progress.

string HeloHostname

Specifies the hostname to be used for the EHLO/HELO command sent to an SMTP server. By default, this property is an empty string which causes the local hostname to be used.

string HttpProxyAuthMethod

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "LOGIN" or "NTLM".

string HttpProxyHostname

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

string HttpProxyPassword

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

int HttpProxyPort

If an HTTP proxy is to be used, set this property to the HTTP proxy port number. (Two commonly used HTTP proxy ports are 8080 and 3128.)

string HttpProxyUsername

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

bool ImmediateDelete

If true (the default) then any method that deletes an email from the POP3 server will also issue a QUIT command to close the session to ensure the message is deleted immediately.

The POP3 protocol is such that the DELE command marks a message for deletion. It is not actually deleted until the QUIT command is sent and the session is closed. If ImmediateDelete is true, then any Chilkat MailMan method that marks a message (or messages) for deletion will also followup with a QUIT command and close the session. If your program sets ImmediateDelete to false, it must make sure to call Pop3EndSession to ensure that messages marked for deletion are actually deleted.

POP3 Session Management

int IncludeRootCert

Controls whether the root certificate in the chain of authentication (i.e. the CA root certificate) is included within the S/MIME signature of a signed email. Note: This property only applies if the EmbedCertChain property is also true.

string LastErrorHtml (read-only)

Retrieves the last-error information in HTML format. When a Chilkat method returns a failure status, the last-error information is saved and can be retrieved until the next method is called on the same object instance.Error information in HTML format for the last method called.

string LastErrorText (read-only)

Retrieves the last-error information in plain-text format. When a Chilkat method returns a failure status, the last-error information is saved and can be retrieved until the next method is called on the same object instance.Error information in plain-text format for the last method called.

string LastErrorXml (read-only)

Retrieves the last-error information in XML format. When a Chilkat method returns a failure status, the last-error information is saved and can be retrieved until the next method is called on the same object instance.Error information in XML format for the last method called.

string LastSendQFilename (read-only)

The name of the file created in the SMTPQ's queue directory for the last email sent via SendQ, SendQ2, or SendMimeQ.

int LastSmtpStatus (read-only)

Returns the last SMTP diagnostic status code. This can be checked after sending an email. SMTP reply codes are defined by RFC 821 - Simple Mail Transfer Protocol.

string LogMailReceivedFilename

A log filename where the MailMan will log each message in the exact form it was received from a POP3 server. This property is provided for help in debugging.

string LogMailSentFilename

A log filename where the MailMan will log the exact message sent to the SMTP server. This property is helpful in debugging.

string MailHost

The hostname of the POP3 server. Do not include "http://" in the hostname. The hostname may also be an IP address string, such as "168.144.70.227".

int MailPort

The port number of the POP3 server. Only needs to be set if the POP3 server is running on a non-standard port. The default value is 110. (If SSL/TLS is used by setting the PopSsl property = true, then this property should probably be set to 995, which is the standard SSL/TLS port for POP3.)

int MaxCount

Limits the number of messages the MailMan will try to retrieve from the POP3 server in a single method call. If you are trying to read a large mailbox, you might set this to a value such as 100 to download 100 emails at a time.

bool OpaqueSigning

When set to true, signed emails are sent using opaque signing. The default is to send clear-text (multipart/signed) emails.

bool Pop3SPA

Controls whether SPA authentication for POP3 is used or not. To use SPA authentication, set this propoerty = true. No other programming changes are required. The default value is false.

int Pop3SessionId (read-only)

0 if no POP3 session is active. Otherwise a positive integer that is incremented with each new POP3 session. It may be used to determine if a new POP3 session has been established.

string Pop3SessionLog (read-only)

This string property accumulates the raw commands sent to the POP3 server, and the raw responses received from the POP3 server. This property is read-only, but it may be cleared by calling ClearPop3SessionLog.

bool Pop3SslServerCertVerified (read-only)

When connecting via SSL, this property is true if the POP3 server's SSL certificate was verified. Otherwise it is set to false.

string PopPassword

The POP3 password.

If the Pop3SPA property is set, the PopUsername and PopPassword properties may be set to the string "default" to cause the component to use the current logged-on credentials (of the calling process) for authentication.

bool PopSsl

Controls whether SSL is used when reading email from a POP3 server. Note: Check first to determine if your POP3 server can accept SSL connections. Also, be sure to set the MailPort property to the SSL POP3 port number, which is typically 995.

string PopUsername

The POP3 login name.

If the Pop3SPA property is set, the PopUsername and PopPassword properties may be set to the string "default" to cause the component to use the current logged-on credentials (of the calling process) for authentication.

int ReadTimeout

The maximum time to wait, in seconds, if the POP3 or SMTP server stops responding. The default value is 30 seconds.

bool ResetDateOnLoad

Controls whether the Date header field is reset to the current date/time when an email is loaded from LoadMbx, LoadEml, LoadMime, LoadXml, or LoadXmlString. The default is false (to not reset the date). To automatically reset the date, set this property equal to true.

int SendBufferSize

The buffer size to be used with the underlying TCP/IP socket for sending. The default value is 32767.

bool SendIndividual

Determines how emails are sent to distribution lists. If true, emails are sent to each recipient in the list one at a time, with the "To"header field containing the email address of the recipient. If false, emails will contain in the "To"header field, and are sent to 100 BCC recipients at a time. As an example, if your distribution list contained 350 email addresses, 4 emails would be sent, the first 3 having 100 BCC recipients, and the last email with 50 BCC recipients.The default is value of this property is true.

int SizeLimit

The MailMan will not try to retrieve mail messages from a POP3 server that are greater than this size limit. The default value is 0 indicating no size limit. The SizeLimit is specified in number of bytes.

string SmtpAuthMethod

This property should usually be left empty. The MailMan will by default choose the most secure login method available to prevent unencrypted username and passwords from being transmitted if possible. However, some SMTP servers may not advertise the acceptable authorization methods, and therefore it is not possible to automatically determine the best authorization method. To force a particular auth method, or to prevent any authorization from being used, set this property to one of the following values: "NONE", "LOGIN", "PLAIN", "CRAM-MD5", or "NTLM".

string SmtpHost

The hostname of the SMTP server. Do not include "http://" in the hostname. The hostname may also be set to an IP address string, such as "168.144.70.227".

Sending Email without an SMTP Server

string SmtpLoginDomain

The Windows domain for logging into the SMTP server. Use this only if your SMTP server requires NTLM authentication, which means your SMTP server uses Integrated Windows Authentication. If there is no domain, this can be left empty.

string SmtpPassword

The password for logging into the SMTP server. Use this only if your SMTP server requires authentication. Chilkat Email.NET supports the LOGIN, PLAIN, CRAM-MD5, and NTLM login methods, and it will automatically choose the most secure method available. Additional login methods will be available in the future.

If NTLM (Windows-Integrated) authentication is used, the SmtpUsername and SmtpPassword properties may be set to the string "default" to cause the component to use the current logged-on credentials (of the calling process) for authentication.

int SmtpPort

The port number of the SMTP server used to send email. Only needs to be set if the SMTP server is running on a non-standard port. The default value is 25. If SmtpSsl is set to true, this property should be set to 465. (TCP port 465 is reserved by common industry practice for secure SMTP communication using the SSL protocol.)

string SmtpSessionLog (read-only)

This string property accumulates the raw commands sent to the SMTP server, and the raw responses received from the SMTP server. This property is read-only, but it may be cleared by calling ClearSmtpSessionLog.

bool SmtpSsl

When set to True, causes the mailman to connect to the SMTP server via the SSL protocol.

bool SmtpSslServerCertVerified (read-only)

If using SSL, this property will be set to true if the SMTP server's SSL certificate was verified when establishing the connection. Otherwise it is set to false.

string SmtpUsername

The login for logging into the SMTP server. Use this only if your SMTP server requires authentication.

Note: In many cases, an SMTP server will not require authentication when sending to an email address local to it's domain. However, when sending email to an external domain, authentication is required (i.e. the SMTP server is being used as a relay).

If the Pop3SPA property is set, the PopUsername and PopPassword properties may be set to the string "default" to cause the component to use the current logged-on credentials (of the calling process) for authentication.

550 5.7.1 Unable to relay

string SocksHostname

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

string SocksPassword

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

int SocksPort

The SOCKS4/SOCKS5 proxy port. The default value is 1080. This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).

string SocksUsername

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

int SocksVersion

May be set to one of the following integer values:

0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.

bool StartTLS

When set to true, causes the mailman to issue a STARTTLS command to switch over to a secure SSL/TLS connection prior to authenticating and sending email. The default value is false.

string Version (read-only)

The version of this component, such as "v1.0.0"

Methods

int CheckMail()

Returns the number of emails available on the POP3 server. Returns -1 on error.

The VerifyPopConnection method can be called to verify basic TCP/IP connectivity with the POP3 server. The VerifyPopLogin method can be called to verify the POP3 login. The Verify* methods are intended to be called as a way of diagnosing the failure when a POP3 method returns an error status.

void ClearBadEmailAddresses()

Clears the list of bad email addresses stored within the Mailman object. When an email-sending method is called, any email addresses rejected by the SMTP server will be cached within the Mailman object. These can be accessed by calling the GetBadEmailAddresses method. This method clears the Mailman's in-memory cache of bad addresses.

void ClearPop3SessionLog()

Clears the contents of the Pop3SessionLog property.

void ClearSmtpSessionLog()

Clears the contents of the SmtpSessionLog property.

bool CloseSmtpConnection()

The mailman object automatically opens an SMTP connection (if necessary) whenever an email-sending method is called. The connection is kept open until explicitly closed by this method. Calling this method is entirely optional. The SMTP connection is also automatically closed when the mailman object is destructed. Thus, if an application calls SendEmail 10 times to send 10 emails, the 1st call will open the SMTP connection, while the subsequent 9 will send over the existing connection (unless a property such as username, login, hostname, etc. is changed, which would force the connection to become closed and re-established with the next mail-sending method call).

Note: This method sends a QUIT command to the SMTP server prior to closing the connection.

Returns 1 for success, 0 for failure.

Minimizing SMTP Sessions

Chilkat.EmailBundle CopyMail()

Copy the email from a POP3 server into a EmailBundle. This does not remove the email from the POP3 server.

Returns a null reference on failure

bool DeleteBundle(Chilkat.EmailBundle bundle)

Removes all the emails present in the bundle from the POP3 email server.

Returns 1 for success, 0 for failure.

bool DeleteByMsgnum(int msgnum)

Marks an email for deletion by message number. WARNING: Be very careful if calling this method. Message numbers are specific to a POP3 session. If a maildrop has (for example) 10 messages, the message numbers will be 1, 2, 3, ... 10. If message number 1 is deleted and a new POP3 session is established, there will be 9 messages numbered 1, 2, 3, ... 9.

IMPORTANT: A POP3 must first be established by either calling Pop3BeginSession explicitly, or implicitly by calling some other method that automatically establishes the session. This method will not automatically establish a new POP3 session (because if it did, the message numbers would potentially be different than what the application expects).

This method only marks an email for deletion. It is not actually removed from the maildrop until the POP3 session is explicitly ended by calling Pop3EndSession.

bool DeleteByUidl(string uidl)

Removes a single email from the server by UIDL.

Returns 1 for success, 0 for failure.

bool DeleteEmail(Chilkat.Email email)

Removes an email from the POP3 server. The email argument is an email that was previously downloaded from the mail server, either in its entirety, or partially (as with GetAllHeaders or GetHeaders).

Returns 1 for success, 0 for failure.

bool DeleteMultiple(Chilkat.StringArray uidlArray)

Removes from the POP3 mail server any email that has a UIDL equal to one of the UIDLs in the StringArray.

Returns 1 for success, 0 for failure.

Using GMail? You'll need to read this information.

Chilkat.Email FetchByMsgnum(int msgnum)

Fetches an email by message number. WARNING: Be very careful if calling this method. Message numbers are specific to a POP3 session. If a maildrop has (for example) 10 messages, the message numbers will be 1, 2, 3, ... 10. If message number 1 is deleted and a new POP3 session is established, there will be 9 messages numbered 1, 2, 3, ... 9.

IMPORTANT: A POP3 must first be established by either calling Pop3BeginSession explicitly, or implicitly by calling some other method that automatically establishes the session. This method will not automatically establish a new POP3 session (because if it did, the message numbers would potentially be different than what the application expects).

Returns a null reference on failure

Chilkat.Email FetchEmail(string uidl)

Fetches an email from the POP3 mail server given its UIDL. Calling this method does not remove the email from the server. A typical program might get the email headers from the POP3 server by calling GetAllHeaders or GetHeaders, and then fetch individual emails by UIDL.

Returns a null reference on failure.

Returns a null reference on failure

VARIANT FetchMime(string uidl)

Fetches an email by UIDL and returns the MIME source of the email in a byte array.

Returns 1 for success, 0 for failure.

VARIANT FetchMimeByMsgnum(int msgnum)

To be documented soon.

Returns 1 for success, 0 for failure.

Chilkat.EmailBundle FetchMultiple(Chilkat.StringArray uidlArray)

Given an array of UIDL strings, fetchs all the emails from the POP3 server whose UIDL is present in the array, and returns the emails in a bundle.

A null reference is returned on failure.

Returns a null reference on failure

Chilkat.EmailBundle FetchMultipleHeaders(Chilkat.StringArray uidlArray, int numBodyLines)

Given an array of UIDL strings, fetchs all the email headers from the POP3 server whose UIDL is present in the array.

Note: The email objects returned in the bundle contain only headers. The attachments will be missing, and the bodies will be mostly missing (only the 1st numBodyLines lines of either the plain-text or HTML body will be present).

Returns a null reference on failure

Chilkat.StringArray FetchMultipleMime(Chilkat.StringArray uidlArray)

Given an array of UIDL strings, fetchs all the emails from the POP3 server whose UIDL is present in the array, and returns the MIME source of each email in an "stringarray" -- an object containing a collection of strings. Returns a null reference on failure.

Returns a null reference on failure

Chilkat.Email FetchSingleHeader(int numBodyLines, int messageNumber)

Fetches a single header by message number. Returns an email object on success, or a null reference on failure.

Note: The email objects returned in the bundle contain only headers. The attachments will be missing, and the bodies will be mostly missing (only the 1st messageNumber lines of either the plain-text or HTML body will be present).

Also Important:Message numbers are specific to a POP3 session (whereas UIDLs are valid across sessions). Be very careful when using this method.

Returns a null reference on failure

Chilkat.Email FetchSingleHeaderByUidl(int numBodyLines, string uidl)

Fetches a single header by UIDL. Returns an email object on success, or a null reference on failure.

Note: The email objects returned in the bundle contain only headers. The attachments will be missing, and the bodies will be mostly missing (only the 1st ARG2 lines of either the plain-text or HTML body will be present).

Returns a null reference on failure

Chilkat.EmailBundle GetAllHeaders(int numBodyLines)

Returns all the emails from the POP3 server, but only the first numBodyLines lines of the body. Attachments are not returned. The emails returned in the bundle are valid email objects, the only difference is that the body is truncated to include only the top numBodyLines lines, and the attachments will be missing.

A null reference is returned on failure.

Returns a null reference on failure

void GetBadEmailAddresses(Chilkat.StringArray strArray)

Returns a string array object containing a list of failed and invalid email addresses that have accumulated during SMTP sends. The list will not contain duplicates. Also, this only works with some SMTP servers -- not all SMTP servers check the validity of each email address.

Note: An SMTP server can only validate the email addresses within it's own domain. External email address are not verifiable at the time of sending.

Chilkat.Email GetFullEmail(Chilkat.Email email)

If a partial email was obtained using GetHeaders or GetAllHeaders, this method will take the partial email as an argument, and download the full email from the server. A new email object (separate from the partial email) is returned. A null reference is returned on failure.

Returns a null reference on failure

Chilkat.EmailBundle GetHeaders(int numBodyLines, int fromIndex, int toIndex)

The same as the GetAllHeaders method, except only the emails from fromIndex to toIndex on the POP3 server are returned. The first email on the server is at index 0.

Returns a null reference on failure.

Returns a null reference on failure

int GetMailboxCount()

Returns the number of emails on the POP3 server, or -1 for failure.

This method is identical to CheckEmail. It was added for clarity.

string GetMailboxInfoXml()

Returns an XML document with information about the emails in a POP3 mailbox. The XML contains the UIDL and size (in bytes) of each email in the mailbox.

Returns a null on failure

int GetMailboxSize()

Returns the total combined size in bytes of all the emails in the POP3 mailbox. This is also known as the "mail drop" size. Returns -1 on failure.

Chilkat.Cert GetPop3SslServerCert()

Returns the POP3 server's SSL certificate. This is available after connecting via SSL to a POP3 server. (To use POP3 SSL, set the PopSsl property = true.)

Returns a null reference if no POP3 SSL certificate is available.

int GetSizeByUidl(string uidl)

Returns the size of an email (including attachments) given the UIDL of the email on the POP3 server. Returns -1 for failure.

Chilkat.Cert GetSmtpSslServerCert()

If using SSL/TLS, this method returns the SMTP server's digital certificate used with the secure connection.

Chilkat.StringArray GetUidls()

Returns the UIDLs of the emails currently stored on the POP3 server.

Returns a null reference on failure

bool IsSmtpDsnCapable()

Contacts the SMTP server and determines if it supports the DSN (Delivery Status Notification) features specified by RFC 3461 and supported by the DsnEnvid, DsnNotify, and DsnRet properties. Returns true if the SMTP server supports DSN, otherwise returns false.

bool IsUnlocked()

Returns true if the mailman is already unlocked, otherwise returns false.

Chilkat.Email LoadEml(string emlFilename)

Loads an email from a .eml file. (EML files contain the MIME source of an email.) Returns a null reference on failure.

Note: MHT files can be loaded into an email object by calling this method.

Returns a null reference on failure

MHT = EML

Chilkat.EmailBundle LoadMbx(string mbxFileName)

Loads a .mbx file containing emails and returns an email bundle. If a Filter is present, only emails matching the filter are returned.

A null reference is returned on failure.

Returns a null reference on failure

Chilkat.Email LoadMime(string mimeText)

Creates and loads an email from a MIME string. Returns a null reference on failure.

Returns a null reference on failure

Chilkat.Email LoadXmlEmail(string emailFilename)

Loads an XML file containing a single email and returns an email object. Returns a null reference on failure.

Returns a null reference on failure

Chilkat.Email LoadXmlEmailString(string xmlString)

Loads an XML string containing a single email and returns an email object. Returns a null reference on failure.

Returns a null reference on failure

Chilkat.EmailBundle LoadXmlFile(string folderPath)

Loads an XML file containing one or more emails and returns an email bundle. If a Filter is present, only emails matching the filter are returned. Returns a null reference on failure.

Returns a null reference on failure

Chilkat.EmailBundle LoadXmlString(string xmlString)

Loads from an XML string containing emails and returns an email bundle. If a Filter is present, only emails matching the filter are returned.

Returns a null reference on failure

string MxLookup(string emailAddress)

Performs a DNS MX lookup to return the mail server hostname based on an email address.

Returns a null on failure

Chilkat.StringArray MxLookupAll(string emailAddress)

Performs a DNS MX lookup to return the list of mail server hostnames based on an email address. The primary server is at index 0. In most cases, there is only one mail server for a given email address.

Returns a null reference on failure

Chilkat.EmailBundle NewBundle()

Creates and returns a new email bundle object.

Returns a null reference on failure

Chilkat.Email NewEmail()

Creates and returns a new email object.

Returns a null reference on failure

bool OpenSmtpConnection()

Explicitly opens a connection to the SMTP server and authenticates (if a username/password was specified). Calling this method is optional because the SendEmail method and other mail-sending methods will automatically open the connection to the SMTP server if one is not already established.

Returns 1 for success, 0 for failure.

Minimizing SMTP Connections

bool Pop3BeginSession()

Call to explicitly begin a POP3 session. It is not necessary to call this method because any method requiring an established POP3 session will automatically connect and login if a session is not already open.

Returns 1 for success, 0 for failure.

More about POP3 Session Management

bool Pop3EndSession()

Call to explicitly end a POP3 session. If the ImmediateDelete property is set to false, and emails marked for deletion will be deleted at this time.

Returns 1 for success, 0 for failure.

More about POP3 Session Management

bool Pop3Noop()

Sends a NOOP command to the POP3 server. This may be a useful method to call periodically to keep a connection open, or to verify that the POP3 connection (session) is open and functioning.

Returns 1 for success, 0 for failure.

bool Pop3Reset()

Sends a RSET command to the POP3 server. If any messages have been marked as deleted by the POP3 server, they are unmarked. Calling Pop3Reset resets the POP3 session to a valid, known starting point.

Returns 1 for success, 0 for failure.

bool QuickSend(string from, string to, string subject, string body, string smtpServer)

A quick way to send an email to a single recipient without having to explicitly create an email object.

Returns 1 for success, 0 for failure.

string RenderToMime(Chilkat.Email email)

When an email is sent by calling SendEmail, it is first "rendered" according to the values of the email properties and contents. It may be digitally signed, encrypted, values substituted for replacement patterns, and header fields "Q"or "B" encoded as needed based on the email. The RenderToMime method performs the rendering, but without the actual sending. The MIME text produced is exactly what would be sent to the SMTP server had SendEmail been called. (The SendEmail method is effectively the same as calling RenderToMime followed by a call to SendRendered.)

The rendered MIME string is returned on success.

Returns a null on failure

VARIANT RenderToMimeBytes(Chilkat.Email email)

To be documented soon...

bool SaveLastError(string filename)

Saves the last error information to an XML formatted file.

bool SendBundle(Chilkat.EmailBundle bundle)

Sends a bundle of emails. This is identical to calling SendEmail for each email in the bundle.

If an error occurs when sending one of the emails in the bundle, it will continue with each subsequent email until each email in the bundle has been attempted (unless a fatal error occurs, in which case the send is aborted).

Because it is difficult or impossible to programmatically identify which emails in the bundle failed and which succeeded, it is best to write a loop that sends each email separately (via the SendEmail method).

Returns 1 for success, 0 for failure.

bool SendEmail(Chilkat.Email email)

Sends a single email.

Important: Some SMTP servers do not actually send the email until the connection is closed. In these cases, it is necessary to call CloseSmtpConnection for the mail to be sent. Most SMTP servers send the email immediately, and it is not required to close the connection.

Returns 1 for success, 0 for failure.

Diagnosing SMTP Failures

SocketError: WSAECONNABORTED when Sending Email (SMTP)

SMTP 553-Relaying Denied

550 5.7.1 Unable to relay

Using undisclosed recipients / Send Failed

sockError: 10053, WSAECONNABORTED An established connection was aborted by the software in your host machine

Sending Email without a Mail Server (so-to-speak)

Invalid Token error when trying to connect with SSL (SMTP, POP3, IMAP, FTP, HTTP)

SMTP SSL Clarification

Read Receipt vs. Delivery Receipt when Sending Email

Validating an Email Address - Unfortunately, Nothing is Perfect

POP-before-SMTP Authentication

bool SendMime(string fromAddr, string recipients, string mimeSource)

Provides complete control over the email that is sent. The MIME text passed in mimeSource (the MIME source of an email) is passed exactly as-is to the SMTP server. The recipients of the email are passed as a string of comma separated email addresses (without friendly names). The fromAddr is the reverse-path email address. This is where bounced email will be delivered. It may be different than the From header field in the mimeSource.

Returns 1 for success, 0 for failure.

int SendMimeBytes(string from, string recipients, VARIANT mimeData)

To be documented soon...

int SendMimeBytesQ(string from, string recipients, VARIANT mimeData)

To be documented soon...

bool SendMimeQ(string fromAddr, string recipients, string mimeSource)

Same as SendMime, except the email is written to the Chilkat SMTPQ's queue directory for background sending from the SMTPQ service.

Returns 1 for success, 0 for failure.

bool SendMimeToList(string fromAddr, string distListFilename, string mimeSource)

Same as SendMime, but the recipient list is read from a text file ( distListFilename) containing one email address per line.

Returns 1 for success, 0 for failure.

bool SendQ(Chilkat.Email email)

Queues an email to be sent using the Chilkat SMTP queue service. This is the same as SendEmail, except the email is written to the SMTPQ's queue directory.

The email is written as a .eml to the SMTPQ's queue directory. The SMTP server hostname, login, password, and send-time parameters are saved as encrypted headers in the .eml. The SMTPQ service watches the queue directory. When a .eml file appears, it loads the .eml, extracts and removes the encrypted information from the header, and sends the email.

Returns 1 for success, 0 for failure.

bool SendQ2(Chilkat.Email email, string queueDir)

Same as SendQ, but the queue directory can be explicitly specified in a method argument.

Returns 1 for success, 0 for failure.

bool SendToDistributionList(Chilkat.Email emailObj, Chilkat.StringArray recipientList)

Send the same email to a list of email addresses.

bool SetDecryptCert2(Chilkat.Cert iCert, Chilkat.PrivateKey iKey)

To be documented soon.

void SetSslClientCert(Chilkat.Cert iCert)

Sets the client-side certificate to be used with SSL connections. This is typically not required, as most SSL connections are such that only the server is authenticated while the client remains unauthenticated.

bool SetSslClientCertPfx(string pfxFilename, string pfxPassword, string certSubjectCN)

To be documented soon...

bool SmtpNoop()

Sends a no-op to the SMTP server. Calling this method is good for testing to see if the connection to the SMTP server is working and valid. The SmtpNoop method will automatically establish the SMTP connection if it does not already exist.

Returns 1 for success, 0 for failure.

bool SmtpReset()

Sends an RSET command to the SMTP server. This method is rarely needed. The RSET command resets the state of the connection to the SMTP server to the initial state (so that the component can proceed with sending a new email). The SmtpReset method would only be needed if a mail-sending method failed and left the connection with the SMTP server open and in a non-initial state. (A situation that is probably not even possible with the Chilkat mail component.)

Returns 1 for success, 0 for failure.

int SshAuthenticatePk(int bSmtp, string sshUsername, Chilkat.SshKey sshPrivateKey)

Authenticates with the SSH server using public-key authentication. bSmtp should be set to true for SMTP SSH tunneling (port forwarding) or false for POP3 SSH tunneling (port forwarding). The corresponding public key must have been installed on the SSH server for the sshUsername. Authentication will succeed if the matching sshPrivateKey is provided.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns 1 for success, 0 for failure.

int SshAuthenticatePw(int bSmtp, string sshLogin, string sshPassword)

Authenticates with the SSH server using a sshLogin and sshPassword. bSmtp should be set to true for SMTP SSH tunneling (port forwarding) or false for POP3 SSH tunneling (port forwarding).

An SSH tunneling (port forwarding) session always begins by first calling SshTunnel to connect to the SSH server, then calling either AuthenticatePw or AuthenticatePk to authenticate.

Note: Once the SSH tunnel is setup by calling SshTunnel and SshAuthenticatePw (or SshAuthenticatePk), all underlying communcations with the POP3 or SMTP server use the SSH tunnel. No changes in programming are required other than making two initial calls to setup the tunnel.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns 1 for success, 0 for failure.

int SshCloseTunnel(int bSmtp)

Closes the SSH tunnel for SMTP or POP3. bSmtp should be set to true for SMTP and false for POP3.

Returns 1 for success, 0 for failure.

int SshTunnel(int bSmtp, string sshServerHostname, int sshPort)

Connects to an SSH server and creates a tunnel for SMTP or POP3. If bSmtp is true, then an SSH tunnel is created for SMTP. If bSmtp is false, the SSH tunnel is created for POP3. The sshServerHostname is the hostname (or IP address) of the SSH server. The sshPort is typically 22, which is the standard SSH port number.

An SSH tunneling (port forwarding) session always begins by first calling SshTunnel to connect to the SSH server, followed by calling either AuthenticatePw or AuthenticatePk to authenticate.

Note: Once the SSH tunnel is setup by calling SshTunnel and SshAuthenticatePw (or SshAuthenticatePk), all underlying communcations with the SMTP or POP3 server use the SSH tunnel. No changes in programming are required other than making two initial calls to setup the tunnel.

Note: Tunnels are setup separately for POP3 and SMTP. The bSmtp indicates whether the tunnel is for SMTP or POP3.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns 1 for success, 0 for failure.

Chilkat.EmailBundle TransferMail()

Downloads and removes all email from a POP3 server. A bundle containing the emails is returned. A null reference is returned on failure.

Returns a null reference on failure

Chilkat.StringArray TransferMultipleMime(Chilkat.StringArray uidlArray)

Same as FetchMultipleMime except that the downloaded emails are also deleted from the server. Returns a null reference on failure.

Returns a null reference on failure

bool UnlockComponent(string code)

Unlocks the component. This must be called once at the beginning of your program (or ASP / ASP.NET page). It is very fast and has negligible overhead. An arbitrary string, such as "Hello World" may be passed to automatically begin a fully-functional 30-day trial.

Returns 1 for success, 0 for failure.

bool VerifyPopConnection()

Return true if a TCP/IP connection can be established with the POP3 server, otherwise returns false.

bool VerifyPopLogin()

Return true if a TCP/IP connection and login is successful with the POP3 server. Otherwise return false.

Chilkat.StringArray VerifyRecipients(Chilkat.Email email)

Initiates sending an email, but aborts just after passing all recipients (TO, CC, BCC) to the SMTP server. This allows your program to collect email addresses flagged as invalid by the SMTP server.

Important: Please read this blog post before using this method: http://www.cknotes.com/?p=249

Returns a null reference on failure

bool VerifySmtpConnection()

Return true if a TCP/IP connection can be established with the SMTP server, otherwise returns false.

bool VerifySmtpLogin()

Return true if a TCP/IP connection and login is successful with the SMTP server. Otherwise returns false.