-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be77de3
commit ca4303c
Showing
5 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
11 changes: 11 additions & 0 deletions
11
EntidadVirtual/ServidorMensajeria&Correo/.idea/ServidorMensajeria&Correo.iml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
EntidadVirtual/ServidorMensajeria&Correo/MandaCorreosPruebas.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import paho.mqtt.client as mqtt_connect | ||
|
||
user = mqtt_connect.Client("C2") | ||
|
||
user.connect('localhost', port=8083) | ||
error = 0 | ||
alarmas = 300000 | ||
tiempoinicial = time.time() | ||
|
||
for i in range(0, alarmas): | ||
user.publish("conjunto1/residencia1/alerta", payload='Alerta, Intruso!!!') | ||
|
||
tiempofinal = time.time() - tiempoinicial | ||
print('Tiempo de envío en segundos:', int(tiempofinal)) | ||
print('Porcentaje de error: ' + str(error) + '%') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,20 @@ | |
|
||
user = mqtt_connect.Client("C1") | ||
|
||
user.connect("157.253.227.89", port=8083) | ||
user.connect('localhost', port=8083) | ||
user.subscribe("conjunto1/residencia1/alerta") | ||
|
||
address = '[email protected]' | ||
sender = '[email protected]' | ||
smtp.login(sender, 'vanessa98') | ||
sender = '[email protected]' | ||
|
||
|
||
def on_message(user, data, message): | ||
tiempoinicial = time.time() | ||
send_msg(message.payload.decode('utf-8'), message.topic) | ||
print('Calidad del mensaje: ', str(message.qos)) | ||
tiempofinal = time.time() - tiempoinicial | ||
print('Tiempo de respuesta en segundos', int(tiempofinal)) | ||
print(' ') | ||
|
||
|
||
def send_msg(mensaje, asunto): | ||
|
@@ -31,8 +34,10 @@ def send_msg(mensaje, asunto): | |
mime_message["Subject"] = asunto | ||
|
||
try: | ||
smtp = smtplib.SMTP('smtp.office365.com') | ||
smtp = smtplib.SMTP('smtp.gmail.com:587') | ||
smtp.ehlo() | ||
smtp.starttls() | ||
smtp.login(sender, 'tatiana vanessa98') | ||
smtp.send_message(mime_message) | ||
print('Correo enviado') | ||
smtp.quit() | ||
|
@@ -41,7 +46,6 @@ def send_msg(mensaje, asunto): | |
|
||
|
||
user.on_message = on_message | ||
|
||
user.loop_start() | ||
time.sleep(1000) | ||
user.loop_stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters