Description |
MailConnect (Magic xpa 4.x)
You connect to the server using the MailConnect function. In order to do this, you need to know the name of your mail server. If you do not know what it is, you can probably find it in your email software’s setup options.
The SMTP server is used to send mail. Some SMTP servers require a user name and password.
When this function is used to connect to a POP3 or an IMAP server, Magic xpa will connect to the user's mailbox on the server. For POP3 and IMAP servers, a user name and password are required.
When connected, the MailConnect function retrieves the new mails in the user's mailbox. New mail that the user receives after the connection has been made will not be available during that connection session but only after a new connection is made. Only one connection can be set to a send mail server and one connection to a receive mail server. If connected twice, the second connection overrides the first.
|
Syntax:
|
MailConnect(type, server, user, password, protocol)
|
Parameters:
|
Type: The server type; 1 = SMTP server, 2 = POP3 server, 3 = IMAP server
|
|
Server: string, address of mail server. This parameter supports the URL:Port format. This lets you define a port number that is not the mail server’s default port.
|
|
User, Password: string, user ID and password of the mailbox
|
|
protocol: numeric, optional argument to enable TLS/SSL support for mail functions.
It can take either of the three values: 0 (for Plain), 1 (for TLS), or 2 (for SSL).
It is regarded when MailFramework=J. If protocol is not mentioned, then the value 0 (for Plain) is taken.
Since version: 4.6.1
|
Returns:
|
When you try to connect to an SMTP mail server: a 0 return value means a successful connection, a negative value means a failed connection, and each negative value represents a specific error. A successful connection to a POP3/IMAP email server is indicated by 0 or a positive value, where each positive value represents the actual number of mails in the mailbox, and each negative value represents a specific error.
|
Note:
|
When you connect to a POP3 mail server, only the new messages are received. When you connect to an IMAP mail server, all existing messages, including both new and seen messages, are received.
|
Exceptions:
|
This function does not use secure connections, so mail servers that require a secured connection, such as TLS or SSL, are not supported. For sending email using a TLS or SSL mail server, see: programs CN21 and RCN21.
|
Example:
|
For an SMTP server named juno.olympus.com, the connection string would be:
MailConnect (1,'juno.olympus.com','','')
|
See also:
|
Mail functions
Troubleshooting: Error -67 with Microsoft Exchange and the MailConnect function
The Online and Rich Client Samples projects (program EL01, EL02, REL01and REL02)
|
|
|
---|