The mgiSendMail Tag

Tag Behavior

Use the mgiSendMail tag to send a formatted email including attachments from the server.


Tag Syntax

The mgiSendMail tag has two modes. Each mode has different required and optional parameters. The modes of mgiSendMail are:

  • sendMail - Sends a formatted email.
  • admin - Creates a web-based interface to manage failed mail.

SendMail Mode

The sendMail mode of the mgiSendMail tag has a beginning tag with three required parameters and eleven optional parameters, a body, and an end tag. The tag form is:

<mgiSendMail mode="sendMail" to="Email Address" 
from="Email Address" cc="Email Address" bcc="Email Address"
replyTo="Email Address" gmtOffset="Hours"
subject="Title" mailServer="SMTP Server"
attachmentData="Data" attachmentFileLocation="File Path" 
sendAsHTML="Yes/No" headerName="Name" headerValue="Value">
MGI Tags, Formatted Text and HTML (when sendAsHTML is set to "Yes")
</mgiSendMail>

Required Parameters:

  • to - The to parameter is the email recipient's email address or a comma delimited list of email addresses for multiple recipients. The to value must be a valid email format. Multiple "to" parameters may also be included in one mgiSendMail tag.
  • from - The from parameter is the sender's email address. The from value must be a valid email format.
  • mailServer - The mailServer is the outgoing SMTP server that is used to send the email. A global outgoing mail server can be enabled by default or always in the region preferences for your domain. If you do not have access to the region preferences for your domain, contact the server administrator. If a global mail server is enabled as "always", then the mail server preference always overrides the mailServer parameter in your region.

Optional Parameters:

  • mode - The mode is the function of the mgiSendMail tag. In "sendMail" mode, the mgiSendMail tag sends a formatted email. "SendMail" is the default mode of the mgiSendMail tag.
  • cc - The cc parameter is the email address or comma delimited list of email addresses for multiple carbon copy recipients. Multiple "cc" parameters may also be included in one mgiSendMail tag.
  • bcc - The bcc parameter is the email address or comma delimited list of email addresses for multiple blind carbon copy recipents. Blind carbon copy addresses do not appear in the email header. Multiple "bcc" parameters may also be included in one mgiSendMail tag.
  • replyTo - The replyTo parameter is the email addresses where recipient email replies are sent. If a replyTo address is supplied, the address must be in a valid email format.
  • subject - The subject is the title of the email. The default subject is blank.
  • gmtOffset - The gmtOffset is the whole or half number of hours the time of the email is offset from Greenwich Mean Time preceeded by a positive (+) or negative (-) sign (e.g., "+5" or "-3.5"). Only half hours may be entered. Other tenths of an hour may not be entered. When the GMTOffset parameter is not present, the local time of the server is sent. A global GMTOffset can be enabled in the region preferences for your domain. If you do not have access to the region preferences for your domain, contact the server administrator. Including a gmtOffset parameter overrides the gmtOffset in the region preferences.
  • attachmentData - The attachmentData is a byte stream of data that is sent as an attachment to the email. Multiple "attachmentData" parameters can be included in one mgiSendMail tag.
  • attachmentFileLocation - The attachmentFileLocation is the relative path to the file that is attached to the email. Multiple "attachmentFileLocation" parameters can be included in one mgiSendMail tag.
  • sendAsHTML - The sendAsHTML parameter determines whether the body of the mgiSendMail tag is sent as HTML or plain text. If the value of the sendAsHTML parameter is "Yes", then the body of the mgiSendMail tag is sent as HTML and can be read as HTML by HTML-enabled email clients. If the value of the sendAsHTML parameter is "No", then the body of the mgiSendMail tag is sent as plain text (even if the body includes HTML tags). The default value is "No". Note: the sendAsHTML parameter is ignored if the headerName and headerContent parameters are included.
  • headerName - The headerName is the name of the email header attribute (e.g., "Content-Type"). Multiple headerName and headerValue pairs are allowed.
  • headerValue- The headerValue is the name of the value of the header attribute (e.g., "text/plain; charset=US-ASCII"). Multiple headerName and headerValue pairs are allowed.

Admin Mode

The admin mode of the mgiSendMail tag has a beginning tag with one required parameter and one optional parameter, a body, and an end tag. The tag form is:

<mgiSendMail mode="admin" displayLimit="Integer">
</mgiSendMail>

Required Parameters:

  • mode - The mode is the function of the mgiSendMail tag. In "admin" mode, the mgiSendMail tag creates a web-based interface that allows you to manage failed emails from the sendMail mode of mgiSendMail.

Optional Parameters:

  • displayLimit - The displayLimit is the maximum number of emails displayed per screen in the administration interface. The default value is 10. The maximum value of the displayLimit parameter is 50.


Example Usage and Output

SendMail Mode

<mgiSendMail to="info@domain.com" from="webmaster@domain.com"
subject="Information Request" mailServer="mail.isp.com"
replyTo="sales@domain.com">
Information Request
*******************

    Name: <mgiPostArgument name="Name">
   Phone: <mgiPostArgument name="Phone">
   Email: <mgiPostArgument name="Email">
</mgiSendMail>

The mgiSendMail tag in this example is used to send a formatted email from a form submission. When the email is received at "info@domain.com", it will be in the following format:

Information Request
*******************

    Name: Jane Lowe
   Phone: (472) 234-7331
   Email: jlowe@aol.com


SendMail Mode - Send As HTML

<mgiSendMail to="post@list.domain.com" from="info@domain.com" 
subject="MUG July Newsletter" mailServer="mail.domain.com" 
sendAsHTML="Yes">

<html>

<head>
<title>MUG July Newsletter</title>
</head>

<body>
<H3 align="center">MUG July Newsletter</H3>
<p><font color="red"><b>July 4th Celebration</b></font>
<p>The MUG July 4th celebration will be held at Pullen Park 
from 1 PM until 7 PM.  A van will transport members to the 
fair grounds for fireworks at 9 PM. Call Jerry at 
555-1122 for more information or reservations
<p><b>Elections</b>
<p>This year's elections will be held at our monthly 
meeting on 15th July. Submit your nominations by 5 PM on 
10th July to <a href="mailto:karen@domain.com">Karen</a>.
</body>

</html>

</mgiSendMail>

This mgiSendMail tag in this example sends an email formatted with HTML tags. Any email client that has an HTML reader will display the email as HTML. If the email client does not have an HTML reader, the email will be displayed as plain text (including the HTML tags). The following is an example of an HTML display in an email client.


Admin Mode

<mgiSendMail mode="admin" displayLimit="25">
</mgiSendMail>

When you access a page with the mgiSendMail tag in admin mode, a database of failed emails displays.

To resend the failed email without modifications, click the "Send" button. To delete the email, click the "Delete" button. To modify the email before it is re-sent, click the "Edit" button. The edit screen displays the following with the full text of the email message shown under "Message Text:"

Modify the SMTP Server, From, Reply-To, To, CC, BCC, or Subject Fields and click the "Save" button. Clicking the Save or Delete button returns you to the original admin interface. To re-send the modified email, click the "Send" button.


Suggested Usage

  • Form Processing
  • Dynamic Emails
  • Online Listserv Registration


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]