Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


represents a mail receiver function that applies fun to any mail message it receives.

Details and OptionsDetails and Options

  • CloudDeploy[MailReceiverFunction[]] yields a CloudObject containing meta-information specifying the email address to which mail for the mail receiver should be sent.
  • For the Wolfram Cloud, the email address is typically of the form receiver+xxxx@wolframcloud.com, where xxxx is a unique ID assigned to each mail receiver.
  • In MailReceiverFunction[fun], fun[assoc] is evaluated whenever a piece of mail is received. The association assoc is derived from the mail received.
  • The following basic primary elements are usually present in the association:
  • "From"sender name and email address
    "FromAddress"sender raw email address
    "Subject"the subject of the email
    "Body"message body as a string
    "Attachments"list of processed attachments as expressions
    "AttachmentData"list of associations giving raw data on attachments
    "ReceiverAddress"email address of the mail receiver function
    "ReceiverRoutingType"whether the receiver is in "To", "Cc", or "Bcc"
  • Additional possible elements related to senders and recipients include:
  • "FromName"sender full name
    "ToList"recipient names and addresses (except receiver function)
    "ToAddressList"recipient addresses (except receiver function)
    "ToNameList"recipient full names (except receiver function)
    "CcList"copied recipient names and addresses
    "CcAddressList"copied recipient addresses
    "CcNameList"copied recipient full names
    "ReturnPath"declared return path for the mail
    "ReplyToList"reply-to names and addresses
    "ReplyToAddressList"reply-to addresses
    "ReplyToNameList"reply-to full names
  • Elements related to the message include:
  • "NewBodyContent"parts of the body that are not replies or forwards
    "QuotedContent"parts of the body that are quoted
  • Elements related to attachments include:
  • "Attachments"list of expressions giving the content of attachments
    "AttachmentNames"list of names assigned to attachments
    "AttachmentAssociations"associations giving content and metadata of attachments
  • Elements related to message identification and threading include:
  • "MessageID"message ID for this message
    "ReplyToMessageID"ID of a message to which this replies, if any
  • Elements related to message routing include:
  • "Precedence"declared mail precedence
    "ReturnReceiptRequested"whether a return receipt is requested
    "DeliveryChainHostnames"hostnames on the mail delivery chain
    "DeliveryChainRecords"full records on the mail delivery chain
  • Elements associated with mail headers include:
  • "HeaderString"complete email headers as a string
    "HeaderRules"list of rules for all headers
    "CharacterEncoding"character encoding for email content
    "ContentType"MIME content type of email body
  • Elements associated with message origination include:
  • "OriginatingMailClient"type of originating mail client
    "OriginatingIPAddress"IP address of the originating client machine
    "OriginatingHostname"hostname of the originating client machine
    "OriginatingCountry"geoIP-inferred originating country
    "OriginatingDate"date and time on client from email headers
    "OriginatingTimezone"client time zone based on email headers
    "ServerOriginatingDate"date and time on originating server
    "ServerOriginatingTimezone"time zone of originating server
  • Special elements of the association include:
  • "Association"the complete association of all available elements
  • MailReceiverFunction has the following options:
  • MailResponseFunctionAutomaticfunction to apply to respond to the sender
    ReturnReceiptFunctionNonefunction to apply if a return receipt is requested
  • The function fun is evaluated in the environment of the owner of the mail receiver function.
  • MailReceiverFunction[fun]["string"] decodes the string as a mail message, and returns the result of applying fun to the resulting association.
  • MailReceiverFunction[fun][File[]] decodes the contents of a file as a mail message.
  • The setting for "AttachmentAssociations" is a list giving an association for each attachment. The elements of this association are typically:
  • "Content"attachment content as an expression
    "Name"name assigned to the attachment
    "MIMEType"MIME type used to encode the content
    "RawContent"raw encoded content as a string
    "ByteCount"number of bytes in the raw encoded content
    "ModificationDate"modification date recorded for the attachment

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Find the sender from the first message in an MBOX file:

Click for copyable input

Deploy a mail receiver that notifies you when a message is received:

Click for copyable input

Log the body content of an email in your cloud account:

Click for copyable input

Send an email to the receiver function and verify the log:

Click for copyable input
Click for copyable input
Introduced in 2015