RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
EmailSend.py
Go to the documentation of this file.
1 from RappCloud.Objects import (
2  File,
3  Payload)
4 
5 from Cloud import (
6  CloudMsg,
7  CloudRequest,
8  CloudResponse)
9 
10 
11 class EmailSend(CloudMsg):
12  """ Email Send Cloud Message object """
13 
14  class Request(CloudRequest):
15  """ Email Send Cloud Request object.
16 
17  EmailSend.Request
18  """
19  def __init__(self, **kwargs):
20  """!
21  Constructor
22 
23  @param **kwargs - Keyword arguments. Apply values to the request attributes.
24  - @ref email
25  - @ref password
26  - @ref server
27  - @ref port
28  - @ref recipients
29  - @ref body
30  - @ref subject
31  - @ref attach_file
32  """
33 
34  ## The user's email username
35  self.email = ''
36  ## The user's email password
37  self.password = ''
38  ## The email server's smtp address, i.e. 'smtp.gmail.com'
39  self.server = ''
40  ## The email server imap port. Leave empty to use default value.
41  self.port = ''
42  ## Email addresses of the recipients
43  self.recipients = []
44  ## The email body
45  self.body = ''
46  ## The email subject
47  self.subject = ''
48  ## Attachment file path. Can be a .zip file that will be decompressed on the server.
49  self.attach_file = ''
50 
51  super(EmailSend.Request, self).__init__(**kwargs)
52 
53 
54  def make_payload(self):
55  """ Create and return the Payload of the Request. """
56  return Payload(
57  email=self.email,
58  passwd=self.password,
59  server=self.server,
60  port=self.port,
61  recipients=self.recipients,
62  body=self.body,
63  subject=self.subject
64  )
65 
66 
67  def make_files(self):
68  """ Create and return Array of File objects of the Request. """
69  # Check if attachment file has been defined as it is optional
70  if self.attach_file != '':
71  return [File(self.attach_file, 'file')]
72  return []
73 
74 
75  class Response(CloudResponse):
76  """ Email Send Cloud Response object.
77 
78  EmailSend.Response
79  """
80  def __init__(self, **kwargs):
81  """!
82  Constructor
83 
84  @param **kwargs - Keyword arguments. Apply values to the request attributes.
85  - @ref error
86  """
87 
88  ## Error message
89  self.error = ''
90  super(EmailSend.Response, self).__init__(**kwargs)
91 
92 
93  def __init__(self, **kwargs):
94  """!
95  Constructor
96 
97  @param **kwargs - Keyword argumen.ts. Apply values to the request attributes.
98  - @ref Request.email
99  - @ref Request.password
100  - @ref Request.server
101  - @ref Request.port
102  - @ref Request.recipients
103  - @ref Request.body
104  - @ref Request.subject
105  - @ref Request.attach_file
106  """
107 
108  # Create and hold the Request object for this CloudMsg
110  # Create and hold the Response object for this CloudMsg
112  super(EmailSend, self).__init__(
113  svcname='email_send', **kwargs)
114 
115 
recipients
Email addresses of the recipients.
Definition: EmailSend.py:43
server
The email server's smtp address, i.e.
Definition: EmailSend.py:39