smtp: SMTP functions

Top  Previous  Next

SMTP functions for sending emails (electronic mail) by using SMTP (Simple Mail Transfer Protocol).

SMTP is an internet standard for email transmission across IP networks that are typically only used for sending messages to a mail server for relaying.

 

The SMTP functions support two ways of sending emails.

 

smtpSend, for simple short messages:

Advantages:

Only the smtpSend function is needed.

The function waits for the mail transfer to complete.

 

Disadvantages:

The function waits for the mail transfer to complete.

Only a short text message.

No attachments.

 

smtpSendX, for advanced messages:

Advantages:

Large text messages.

Message text can be built over time.

File attachments.

Asynchronous mail transfer (depending on the situation, this can also be a disadvantage).

Mail transfer progress can be monitored.

 

Disadvantages:

Several functions are required to build and send an email.

 

The following sequence is required to make and send the email:

1.

smtpNew

To create the email.

2.

smtpAddText

To add text to the email message (repeatedly for large messages).

3.

smtpAddAttachment

To attach file(s) to the email.

4.

smtpSendX

To start sending the email.

5.

smtpAwaitCompletion

To wait for the mail transfer to complete (optional).

6.

smtpStatus

To monitor mail transfer progress (optional).

 

 

The following functions are used to access the SMTP interface:

 


smtpOpen

Opens the SMTP interface.


smtpClose

Closes the SMTP interface.


smtpSetConfig

Sets the SMTP configuration.


smtpGetConfig

Gets the SMTP configuration.


smtpSend

Sends an email.


smtpNew

Creates a new email.


smtpAddText

Adds text to an email.


smtpAddAttachment

Attaches a file to an email.


smtpSendX

Starts sending an email.


smtpCancel

Cancels a mail transfer.


smtpStatus

Gets the status of an email.


smtpAwaitCompletion

Waits for mail transfer to be completed.

 

 


The implementation of SMTP has the following limitations:

The outbox can hold two emails simultaneously.

All email addresses are limited to 40 characters and a single address.

The message text of an advanced email is restricted to a maximum length of 4095 characters.

It is possible to attach a maximum of one file to an email.

A network interface connection must be available.