Class SendMail

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class SendMail
    extends TypedAtomicActor
    Upon firing, send email to the specified recipient. This actor uses the SMTP protocol and will prompt for a password upon being first invoked. The password is sent encrypted.

    By default, this actor will not actually send email, but will rather produce the formatted email on its output port. The reason for this is that sending email should be done with some hesitation, since it is easy with such an actor to create a flood of email that will have undesirable effects. To get the actor to actually send email, change the value of the reallySendMail parameter to true. Upon completion of an execution, reallySendMail will be set back to false (in the wrapup() method) to help prevent accidental duplicate mailings.

    This actor requires the JavaMail 1.5 javax.mail.jar file be in the classpath.

    To use this actor, download javax.mail.jar https://java.net/projects/javamail/pages/Home and place it in $PTII/vendors/misc/javamail. Below are the steps:

        cd $PTII/vendors/misc/javamail
         wget --no-check-certificate http://java.net/projects/javamail/downloads/download/javax.mail.jar
         cd $PTII
         ./configure
      

    In Eclipse, you will then need to refresh the project.

    If you are using Google as your smtp provider, then you may need to modify your Google account to Allow less secure apps to access your account.

    This is because this actor does not support OAuth 2.0. Allow less secure apps to access accounts Frequently Asked Questions (FAQ) says:

    What criteria is used to identify an application as being "less secure"?

    Applications that rely on plain username/password authentication to access an account programmatically are considered less secure than those using modern day security standards such as OAuth 2.0.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • attach

        public FileParameter attach
        File to attach, if any. By default, this is empty, which means to not attach any file.
      • cc

        public PortParameter cc
        Email address to copy on the message.
      • from

        public PortParameter from
        Email address from which this is sent.
      • message

        public PortParameter message
        The message to send. This defaults to an empty string.
      • output

        public TypedIOPort output
        Output to which the formatted message is sent. The type of this output is string.
      • password

        public PortParameter password
        Password port of the account.
      • replyTo

        public PortParameter replyTo
        The address to which replies should be directed. This is a comma-separated list that defaults to an empty string, which indicates that the reply should go to the address specified by from.
      • reallySendMail

        public Parameter reallySendMail
        If true, then actually send the email. This is a boolean that defaults to false, meaning that the message is only sent to the output port. This parameter will be set back to false in the wrapup() method, to help prevent duplicate mailings.
      • SMTPHostName

        public PortParameter SMTPHostName
        Host name for the send mail server.
      • SMTPPort

        public PortParameter SMTPPort
        Outgoing SMTP mail port.
      • SMTPUserName

        public PortParameter SMTPUserName
        User name for the send mail server.
      • enableSSL

        public Parameter enableSSL
        Enable the Secure Sockets Layer (SSL) protocol.
      • subject

        public PortParameter subject
        The subject line. This defaults to an empty string.
      • to

        public PortParameter to
        Email address(es) to which this is sent. This is a comma-separated list that defaults to "nobody1@nowhere.com, nobody2@nowhere.com".