MailReceiverFunction

MailReceiverFunction[fun]

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

Details and Options

  • CloudDeploy[MailReceiverFunction[]] yields a CloudObject containing metainformation 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
    "OriginatingDate"date and time from message headers
    "OriginatingTimeZone"time zone from message headers
    "Body"message body as a string
    "ToList"recipient names and addresses
    "ToAddressList"recipient addresses
    "ToNameList"recipient full names
    "CcList"copied recipient names and addresses
    "CcAddressList"copied recipient addresses
    "CcNameList"copied recipient full names
    "BccList"blind-copied recipients (for Sent folder only)
    "ReplyToList"reply-to names and addresses
    "ReplyToAddressList"reply-to addresses
    "ReplyToNameList"reply-to full names
    "MessageID"unique ID for this message
    "ReplyToMessageID"ID of a message to which this replies, if any
    "AttachmentList"list of processed attachments as expressions
    "AttachmentDetails"lists of associations giving content and attachment elements
    "ReceiverAddress"email address of the mail receiver function
    "ReceiverRoutingType"whether the receiver is in "To", "Cc", or "Bcc"
  • Additional advanced properties of MailReceiverFunction include all elements available through "MBOX" import.
  • 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.

Examples

open allclose all

Basic Examples  (3)

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

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

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

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

Scope  (1)

Get a full message as a Dataset from an MBOX file:

Applications  (2)

Create an email account that exports an attachment to the web:

Send an image to the receiver:

View the exported attachment in a browser:

Automatically send a custom receipt confirmation:

A response will automatically be computed and sent:

Properties & Relations  (1)

ChannelReceiverFunction works analogously to MailReceiverFunction on channel broker messages:

Send a message to the associated channel and verify the log:

Introduced in 2015
 (10.2)
 |
Updated in 2016
 (11.0)