rpa-suite 1.3.6__py3-none-any.whl → 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rpa_suite/core/email.py +0 -212
- {rpa_suite-1.3.6.dist-info → rpa_suite-1.4.0.dist-info}/METADATA +3 -3
- {rpa_suite-1.3.6.dist-info → rpa_suite-1.4.0.dist-info}/RECORD +6 -6
- {rpa_suite-1.3.6.dist-info → rpa_suite-1.4.0.dist-info}/WHEEL +0 -0
- {rpa_suite-1.3.6.dist-info → rpa_suite-1.4.0.dist-info}/licenses/LICENSE +0 -0
- {rpa_suite-1.3.6.dist-info → rpa_suite-1.4.0.dist-info}/top_level.txt +0 -0
rpa_suite/core/email.py
CHANGED
@@ -10,17 +10,6 @@ from rpa_suite.functions._printer import alert_print, error_print, success_print
|
|
10
10
|
from rpa_suite.core.validate import email_validator
|
11
11
|
|
12
12
|
|
13
|
-
"""
|
14
|
-
smtp_server:str = "smtp.hostinger.com",
|
15
|
-
smtp_port:str = 465,
|
16
|
-
email_user:str = "bot@vettracode.com",
|
17
|
-
email_password:str = "Bot@#2025",
|
18
|
-
email_to: str = "camilo.costa1993@gmail.com",
|
19
|
-
attachments: list[str] = [],
|
20
|
-
subject_title: str = 'titulo teste',
|
21
|
-
body_message: str = '<p>mensagem de teste</p>'
|
22
|
-
"""
|
23
|
-
|
24
13
|
class Email():
|
25
14
|
|
26
15
|
smtp_server:str = "smtp.hostinger.com",
|
@@ -140,204 +129,3 @@ class Email():
|
|
140
129
|
|
141
130
|
except Exception as e:
|
142
131
|
error_print(f"Ocorreu um erro geral na função sendmail: {str(e)}")
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
def send_by_smtp( self,
|
147
|
-
email_from: str,
|
148
|
-
pass_from: str,
|
149
|
-
email_to: list[str],
|
150
|
-
subject_title: str,
|
151
|
-
body_message: str,
|
152
|
-
image_footer: str = None,
|
153
|
-
attachments: list[str] = None,
|
154
|
-
type_content: str = 'html',
|
155
|
-
smtp_server: str = 'smtp.office365.com',
|
156
|
-
smtp_port: int = 587,
|
157
|
-
authentication_tls: bool = True,
|
158
|
-
display_message: bool = True,
|
159
|
-
) -> dict:
|
160
|
-
|
161
|
-
"""
|
162
|
-
Function responsible for sending emails ``(SMTP)``, accepts ``list of recipients`` and possibility
|
163
|
-
of ``attaching files``. \n
|
164
|
-
|
165
|
-
Parameters:
|
166
|
-
----------
|
167
|
-
``email_from: str`` - email from who will send the email.
|
168
|
-
``pass_from: str`` - password of the account used, advised to isolate the password elsewhere.
|
169
|
-
``email_to: list[str]`` - list of emails to which the emails will be sent.
|
170
|
-
``subject_title: str`` - email title.
|
171
|
-
``body_message: str``- body message of the email.
|
172
|
-
``image_footer: str`` - image footer of body message of the email.
|
173
|
-
``attachments: list[str]`` - list with path of attachments if any. (default None).
|
174
|
-
``type_content: str`` - type of message content can be 'plain' or 'html' (default 'html').
|
175
|
-
``smtp_server: str`` - server to be used to connect with the email account (default 'smtp.office365.com')
|
176
|
-
``smtp_port: int`` - port to be used on this server (default 587 - TLS), commum use 465 for SSL authentication
|
177
|
-
``authentication_tls: bool`` - authentication method (default True), if False use SSL authentication
|
178
|
-
|
179
|
-
Return:
|
180
|
-
----------
|
181
|
-
>>> type:dict
|
182
|
-
a dictionary with all information that may be necessary about the emails.
|
183
|
-
Respectively being:
|
184
|
-
* 'success': bool - if there was at least one successful shipment
|
185
|
-
* 'all_mails': list - list of all emails parameterized for sending
|
186
|
-
* 'valid_mails': list - list of all valid emails for sending
|
187
|
-
* 'invalid_mails': list - list of all invalid emails for sending
|
188
|
-
* 'qt_mails_sent': int - effective quantity that was sent
|
189
|
-
* 'attchament': bool - if there are attachments
|
190
|
-
* 'qt_attach': int - how many attachments were inserted
|
191
|
-
|
192
|
-
Description: pt-br
|
193
|
-
----------
|
194
|
-
Função responsavel por enviar emails ``(SMTP)``, aceita ``lista de destinatários`` e possibilidade
|
195
|
-
de ``anexar arquivos``. \n
|
196
|
-
|
197
|
-
Parametros:
|
198
|
-
----------
|
199
|
-
``email_from: str`` - email de quem ira enviar o email.
|
200
|
-
``pass_from: str`` - senha da conta utilizada, aconselhado isolar a senha em outro local.
|
201
|
-
``email_to: list[str]`` - lista de emails para os quais serão enviados os emails.
|
202
|
-
``subject_title: str`` - titulo do email.
|
203
|
-
``body_message: str``- mensagem do corpo do email.
|
204
|
-
``image_footer: str`` - imagem de rodapé do corpo do email.
|
205
|
-
``attachments: list[str]`` - lista com caminho de anexos se houver. (default None).
|
206
|
-
``type_content: str`` - tipo de conteudo da mensagem pode ser 'plain' ou 'html' (default 'html').
|
207
|
-
``smtp_server: str`` - servidor a ser utilizado para conectar com a conta de email (default 'smtp.office365.com')
|
208
|
-
``smtp_port: int`` - porta a ser utilizada nesse servidor (default 587 - TLS), comum usar 465 para autenticação por SSL
|
209
|
-
``authentication_tls: bool`` - metódo de autenticação (default True), caso Falso usa autenticação por SSL
|
210
|
-
|
211
|
-
Retorno:
|
212
|
-
----------
|
213
|
-
>>> type:dict
|
214
|
-
um dicionário com todas informações que podem ser necessarias sobre os emails.
|
215
|
-
Sendo respectivamente:
|
216
|
-
* 'success': bool - se houve pelo menos um envio com sucesso
|
217
|
-
* 'all_mails': list - lista de todos emails parametrizados para envio
|
218
|
-
* 'valid_mails': list - lista de todos emails validos para envio
|
219
|
-
* 'invalid_mails': list - lista de todos emails invalidos para envio
|
220
|
-
* 'qt_mails_sent': int - quantidade efetiva que foi realizado envio
|
221
|
-
* 'attchament': bool - se há anexos
|
222
|
-
* 'qt_attach': int - quantos anexos foram inseridos
|
223
|
-
"""
|
224
|
-
|
225
|
-
try:
|
226
|
-
# Local Variables
|
227
|
-
result: dict = {
|
228
|
-
'success': bool,
|
229
|
-
'all_mails': list,
|
230
|
-
'valid_mails': list,
|
231
|
-
'invalid_mails': list,
|
232
|
-
'qt_mails_sent': int,
|
233
|
-
'attchament': bool,
|
234
|
-
'qt_attach': int
|
235
|
-
}
|
236
|
-
email_valido = []
|
237
|
-
email_invalido = []
|
238
|
-
|
239
|
-
# Preprocessing
|
240
|
-
result['success'] = False
|
241
|
-
result['qt_mails_sent'] = 0
|
242
|
-
result['attchament'] = False
|
243
|
-
|
244
|
-
msg = MIMEMultipart()
|
245
|
-
msg['From'] = email_from
|
246
|
-
msg['Subject'] = subject_title
|
247
|
-
|
248
|
-
# Email Body Content
|
249
|
-
msg.attach(MIMEText(body_message, type_content))
|
250
|
-
|
251
|
-
# Add image Footer
|
252
|
-
if image_footer:
|
253
|
-
try:
|
254
|
-
with open(image_footer, 'rb') as img:
|
255
|
-
msg_image = MIMEImage(img.read())
|
256
|
-
msg_image.add_header('Content-ID', '<logo>')
|
257
|
-
# Notice: Content-ID correlact at "cid" on tag <img> at body mail
|
258
|
-
msg.attach(msg_image)
|
259
|
-
except FileNotFoundError as e:
|
260
|
-
alert_print(f'File Not Found! Error: {str(e)}')
|
261
|
-
except Exception as e:
|
262
|
-
error_print(f'An Error ocurred, during set image: <{image_footer}> as MIMEImage! Error: {str(e)}')
|
263
|
-
|
264
|
-
# Add Attachment
|
265
|
-
if attachments:
|
266
|
-
result['qt_attach'] = 0
|
267
|
-
result['attchament'] = True
|
268
|
-
for path_to_attach in attachments:
|
269
|
-
file_name = os.path.basename(path_to_attach)
|
270
|
-
attachs = open(path_to_attach, 'rb')
|
271
|
-
part = MIMEBase('application', 'octet-stream')
|
272
|
-
part.set_payload((attachs).read())
|
273
|
-
encoders.encode_base64(part)
|
274
|
-
part.add_header('Content-Disposition', "attachment; filename= %s" % file_name)
|
275
|
-
msg.attach(part)
|
276
|
-
result['qt_attach'] += 1
|
277
|
-
else:
|
278
|
-
result['attchament'] = False
|
279
|
-
result['qt_attach'] = 0
|
280
|
-
|
281
|
-
# SMTP server config
|
282
|
-
try:
|
283
|
-
|
284
|
-
# authentication TLS False -> Using SSL authentication
|
285
|
-
if authentication_tls:
|
286
|
-
|
287
|
-
server_by_smtp = smtplib.SMTP(smtp_server, smtp_port)
|
288
|
-
server_by_smtp.starttls()
|
289
|
-
server_by_smtp.login(email_from, pass_from)
|
290
|
-
email_content = msg.as_string()
|
291
|
-
|
292
|
-
else: # auth with SSL
|
293
|
-
|
294
|
-
# Conexão com o servidor SMTP usando SSL
|
295
|
-
server_by_smtp = smtplib.SMTP_SSL(smtp_server, smtp_port)
|
296
|
-
server_by_smtp.login(email_from, pass_from)
|
297
|
-
email_content = msg.as_string()
|
298
|
-
|
299
|
-
# Treats the email list before trying to send, keeping only valid emails
|
300
|
-
try:
|
301
|
-
for emails in email_to:
|
302
|
-
try:
|
303
|
-
v = email_validator.validate_email(emails)
|
304
|
-
email_valido.append(emails)
|
305
|
-
|
306
|
-
except email_validator.EmailNotValidError:
|
307
|
-
email_invalido.append(emails)
|
308
|
-
|
309
|
-
except Exception as e:
|
310
|
-
error_print(f'Error while trying to validate email list: {str(e)}')
|
311
|
-
|
312
|
-
# Attaches the treated email list to perform the sending
|
313
|
-
msg['To'] = ', '.join(email_valido)
|
314
|
-
for email in email_valido:
|
315
|
-
try:
|
316
|
-
server_by_smtp.sendmail(email_from, email, email_content)
|
317
|
-
result['qt_mails_sent'] += 1
|
318
|
-
result['all_mails'] = email_to
|
319
|
-
|
320
|
-
except smtplib.SMTPException as e:
|
321
|
-
error_print(f"The email: {email} don't sent, caused by error: {str(e)}")
|
322
|
-
|
323
|
-
#server_by_smtp.quit()
|
324
|
-
result['success'] = True
|
325
|
-
if display_message: success_print(f'Email(s) Sent!')
|
326
|
-
|
327
|
-
|
328
|
-
except smtplib.SMTPException as e:
|
329
|
-
result['success'] = False
|
330
|
-
error_print(f'Error while trying sent Email: {str(e)}')
|
331
|
-
|
332
|
-
finally:
|
333
|
-
server_by_smtp.quit()
|
334
|
-
|
335
|
-
# Postprocessing
|
336
|
-
result['valid_mails'] = email_valido
|
337
|
-
result['invalid_mails'] = email_invalido
|
338
|
-
|
339
|
-
return result
|
340
|
-
|
341
|
-
except Exception as e:
|
342
|
-
error_print(f'Error function: {self.send_email.__name__}! Error: {str(e)}.')
|
343
|
-
return None
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: rpa_suite
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.4.0
|
4
4
|
Summary: Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.
|
5
5
|
Author: Camilo Costa de Carvalho
|
6
6
|
Author-email: camilo.carvalho@triasoftware.com.br
|
@@ -24,7 +24,7 @@ Requires-Dist: email_validator
|
|
24
24
|
Requires-Dist: loguru
|
25
25
|
Requires-Dist: typing
|
26
26
|
Requires-Dist: pillow
|
27
|
-
Requires-Dist:
|
27
|
+
Requires-Dist: pyautogui
|
28
28
|
Dynamic: author
|
29
29
|
Dynamic: author-email
|
30
30
|
Dynamic: classifier
|
@@ -186,7 +186,7 @@ Lançamento: *20/02/2024*
|
|
186
186
|
|
187
187
|
Status: Em desenvolvimento.
|
188
188
|
|
189
|
-
### Notas da atualização: 1.
|
189
|
+
### Notas da atualização: 1.4.0
|
190
190
|
|
191
191
|
- Correções de bugs em diversas funções relacionadas a tempo: *exec_at_hour* , *wait_for_exec* , *exec_and_wait*
|
192
192
|
- Correções de bugs com tempo superior a 10 minutos nas funções de data: *get_hms* e *get_dma*
|
@@ -4,7 +4,7 @@ rpa_suite/core/__init__.py,sha256=VROMsrhKGMqUlstH8cEqp5fwRVC12d3U3_XoxoKOzyg,28
|
|
4
4
|
rpa_suite/core/clock.py,sha256=qGF_fn0_n19WX4GLtzCrwrJmna9HtzfrhLYramOGZm8,12709
|
5
5
|
rpa_suite/core/date.py,sha256=dgg-A5GL67MPFP5_0Ie61ymC9pCyDmoVgCJ10zzStrw,5363
|
6
6
|
rpa_suite/core/dir.py,sha256=cwwvlPeXFEsoVFdu38Jsfw98t3CbshdS79m5D_y2txQ,7848
|
7
|
-
rpa_suite/core/email.py,sha256=
|
7
|
+
rpa_suite/core/email.py,sha256=yW0x4rDjZZoJ5WDB4C4vWkp25MDfdGSlM9KepBxQV9I,5292
|
8
8
|
rpa_suite/core/file.py,sha256=AgXmlyU_AiJ54sKwa8aTWyCjVUfuFhC9-0_m6U6zS7Y,8916
|
9
9
|
rpa_suite/core/log.py,sha256=t5TEMHuWMkx9psbbeIyPy3VHs8MJDaSh1h0rdMaYnro,10841
|
10
10
|
rpa_suite/core/print.py,sha256=PvEBm7TNNdZFa_qNX67i1JmPVToTBe7I1tQ73B17Onk,5122
|
@@ -18,8 +18,8 @@ rpa_suite/functions/_logger.py,sha256=gTYO9JlbX5_jDfu_4FTTajJw3_GotE2BHUbDDB1Hf5
|
|
18
18
|
rpa_suite/functions/_printer.py,sha256=r72zeobAi2baVbYgbfFH0h5-WMv4tSDGPNlcpZen7O0,3949
|
19
19
|
rpa_suite/functions/_variables.py,sha256=vCcktifFUriBQTyUaayZW8BlE8Gr7VP-tFbfomKOS5U,312
|
20
20
|
rpa_suite/functions/_variables_uru.py,sha256=xRqYp49l1fFNrHczOmJ6Pqw1PKIWs0f9kxlgvuYGYys,303
|
21
|
-
rpa_suite-1.
|
22
|
-
rpa_suite-1.
|
23
|
-
rpa_suite-1.
|
24
|
-
rpa_suite-1.
|
25
|
-
rpa_suite-1.
|
21
|
+
rpa_suite-1.4.0.dist-info/licenses/LICENSE,sha256=5D8PIbs31iGd9i1_MDNg4SzaQnp9sEIULALh2y3WyMI,1102
|
22
|
+
rpa_suite-1.4.0.dist-info/METADATA,sha256=1GclteyzCMHGQ-Hl7TS6yOtvcrOGHH8oEWSRdeaiZdo,9351
|
23
|
+
rpa_suite-1.4.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
24
|
+
rpa_suite-1.4.0.dist-info/top_level.txt,sha256=HYkDtg-kJNAr3F2XAIPyJ-QBbNhk7q6jrqsFt10lz4Y,10
|
25
|
+
rpa_suite-1.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|