MvSMTP#
Sends email TO an email address FROM an email address using the SMTP protocol and optionally a copy CC to one or more email addresses. You may specify a SUBJECT
. MAILHOST
must contain the domain name or IP address of the SMTP server.
<MvSMTP FROM = "string: { expression } | string: { expression }"
TO = "string: { expression } | literal"
CC = "string: { expression } | literal"
SUBJECT = "string: { expression } | literal"
FLAGS = "string: { expression } | literal"
MAILHOST = "string: { expression } | literal"
PORT = "string: { number } | literal number"
USERNAME = "string: { expression } | literal"
PASSWORD = "string: { expression } | literal">
</MvSMTP>
Miva Script provides tags that can send and receive email. <MvSMTP>
is used to send mail from any valid SMTP mail server, and Miva Script documents can receive email by becoming POP3 clients using <MvPOP>
.
Attributes#
Attribute | Description |
---|---|
FROM |
Required. The sender’s email address; no additional data should be included, such as a display name. To set a display name, you must use the "noheaders" flag in the FLAGS attribute and create all necessary headers yourself, including From, To and Subject. |
TO |
Required. Recipient email address, or comma delimited list of email addresses. No additional data should be included, such as a display name. To set a display name, you must use the “noheaders” flag in the FLAGS attribute and create all necessary headers yourself, including From, To and Subject. |
CC |
Optional recipient email address or comma delimited list of email addresses. |
SUBJECT |
If creating your own email headers via the FLAGS="noheaders" option, the subject should not be specified as an MvSMTP SUBJECT attribute; you will need to define it manually as part of your overall headers. If using the SUBJECT attribute and not generating your own headers, then this value will set the subject of the outbound email via a Subject: header. If no subject is specified, and noheaders is not used, then the text ‘no subject’ is used as the default subject. |
FLAGS |
Optional. Contains a comma separated list of one or more of the following flags: tls (Specifies that implicit TLS/SSL should be used for transport encryption), starttls (Specifies that the SMTP STARTTLS command should be used for transport encryption), noheaders (Prevents the default headers (Date, From, To, CC, X-Mailer and Subject) from being included in the message body. MvSMTP users that supply this flag must manually generate those headers). |
MAILHOST |
Required domain name or IP address of a host that understands SMTP. |
PORT |
Optional. Defaults to 25 . |
USERNAME |
Optional. Used for SMTP authentication. |
PASSWORD |
Optional. If specified, SMTP authentication will be used. MvSMTP supports the following authentication schemes: DIGEST-MD5, CRAM-MD5, PLAIN, LOGIN. The scheme used will be the first scheme from this list which is supported by the mail server. |
Mail headers, if present, must be placed on the line directly after the <MvSMTP>
tag. Whether or not there are mail headers, the line before the message contents must be left blank.
Enter the text of your message between the blank line and the </MvSMTP>
tag. The message can also be generated by other Miva Script tags between the <MvSMTP>
and </MvSMTP>
tags; for example, an <MvCALL>
tag could be used to obtain a text file.
Address Formats#
For the addresses supplied in the MvSMTP FROM and TO variables, only the email addresses should be set; no additional information, such as display names, should be included here.
Most SMTP servers will accept an email address as either just the email address itself, or the address surrounded by brackets, such as <user@domain.com>
. There may be unusual servers that require the address in one format but will reject the other, so you may need to modify your code if you encounter issues. Alternatively, if there is a user interface or configuration data related to the code that generates the email, including a check box or value for the end user to enable or disable the adding of angle brackets would be recommended.
Mail Headers#
Immediately following the <MvSMTP>
script tag will be your email headers. The body of your email message must be separated from <MvSMTP>
by a blank line and then ended by the </MvSMTP>
tag. You can add any additional headers you choose, but you should ideally never let a header be longer than 78 characters per line. If you make use of the “noheaders” value in the FLAGS
attribute to MvSMTP, then NO headers will be pre-defined for you, including From, To and Subject, so you must create these manually before the blank line and message body. From and To headers should take the following format (with optional display name):
From: “Display Name” user@domain.com To: “Display Name” user@domain.com
Mail headers could contain for example: Reply-To, Return-Path, or Sender. Mail headers, if present, must be placed on the line directly after the <MvSMTP>
tag. Whether or not there are mail headers, the line before the message contents must be left blank.
Example#
This example adds the From: and To: real names header to the message.
<MvSMTP TO="fox.mulder@fbi.gov"
FROM="roy.cropper@alien_encounters.org"
MAILHOST="mail.alien_encounters.org"
CC="dana.scully@fbi.gov,toyah@alien_encounters.org"
SUBJECT="Weatherfield Alien Abduction Society">
From: "Roy Cropper" <roy.cropper@alien_encounters.org>
To: "Fox Mulder" <fox.mulder@fbi.gov>
Friends: The next meeting of the Society will be on April 16.
</MvSMTP>
To understand how <MvSMTP>
handles headers, you need to understand how mail messages are handled generally. Normally users use an email client program to create a mail message. When sent, another program called a mail server receives the message. Because there are many different implementations of mail clients and mail servers, the specific tasks that each one carries out will differ from program to program. In particular, some mail clients and some mail servers will interpret various mail headers, and some won’t. Miva Script, acts as a mail client when it encounters an <MvSMTP>
tag, interprets only the data passed to it with the TO, FROM, CC, and SUBJECT attributes, and generates the appropriate headers and SMTP codes for this data. Any other headers are passed to the mail server unchanged. They become the responsibility of the server; how they are processed depends on the server configuration. For this reason, headers such as Bcc, which require extra processing, are not guaranteed to have the expected effect. You should test the specified MAILHOST for any extra headers that you intend to use.