Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dstuebe/2853394 to your computer and use it in GitHub Desktop.
Save dstuebe/2853394 to your computer and use it in GitHub Desktop.
Script to send an actual email through the user notification service
from interface.objects import DeliveryMode, UserInfo
from pyon.event.event import EventPublisher
#---------------------------------------------------------------------------------
# Create email notification
#---------------------------------------------------------------------------------
rr = pn.resource_registry
user = UserInfo(name = 'user')
user_id, _ = rr.create(user)
uns = pn.user_notification
notification_id = uns.create_email(event_type='ResourceLifecycleEvent',
event_subtype=None,
origin='Some_Resource_Agent_ID1',
origin_type=None,
user_id=user_id,
email='stu3b3@gmail.com',
mode = DeliveryMode.DIGEST,
message_header='message_header',
parser='parser',
period=1)
#-------------------------------------------------------
# publish an event for each notification to generate the emails
#-------------------------------------------------------
rle_publisher = EventPublisher("ResourceLifecycleEvent")
rle_publisher.publish_event(origin='Some_Resource_Agent_ID1', description="RLE test event for email")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment