public class SendMail extends TypedAtomicActor
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.
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
FileParameter |
attach
File to attach, if any.
|
PortParameter |
cc
Email address to copy on the message.
|
Parameter |
enableSSL
Enable the Secure Sockets Layer (SSL) protocol.
|
PortParameter |
from
Email address from which this is sent.
|
PortParameter |
message
The message to send.
|
TypedIOPort |
output
Output to which the formatted message is sent.
|
PortParameter |
password
Password port of the account.
|
Parameter |
reallySendMail
If true, then actually send the email.
|
PortParameter |
replyTo
The address to which replies should be directed.
|
PortParameter |
SMTPHostName
Host name for the send mail server.
|
PortParameter |
SMTPPort
Outgoing SMTP mail port.
|
PortParameter |
SMTPUserName
User name for the send mail server.
|
PortParameter |
subject
The subject line.
|
PortParameter |
to
Email address(es) to which this is sent.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
SendMail(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
boolean |
postfire()
Update the parameters based on any available inputs
and then send one email message.
|
void |
preinitialize()
Set up the properties for the SMTP protocol.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
fire, isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, initialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public FileParameter attach
public PortParameter cc
public PortParameter from
public PortParameter message
public TypedIOPort output
public PortParameter password
public PortParameter replyTo
public Parameter reallySendMail
public PortParameter SMTPHostName
public PortParameter SMTPPort
public PortParameter SMTPUserName
public Parameter enableSSL
public PortParameter subject
public PortParameter to
public SendMail(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.IllegalActionException
- If the actor cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the superclass throws it.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If any of several errors
occur while attempting to send the message.