Hi, I'm using Mutt to send an email in a Python script and it works fine. But when I connect by Putty and run the script from Putty when the program reaches the sending part of the email with Mutt it does not send it. If I execute it directly on Raspbian it does it right.
Why is this? I need to use Putty so I do not have to always be in front of the physical machine.
The code for that part of the program is this:
if distancia > 10 and a == 0: # Si la distancia es mayor que 10cms
fecha = time.strftime("%d%m%Y-%H%M%S") # En esta variable se guarda la fecha actual y la hora para renombrar la foto guardada
fecha_completa = time.strftime("%c")
print ("La distancia es mayor de 10 cms. Alarma activada!!") # Se interrumpe el bucle y se muestra un aviso
GPIO.output(GPIO_LED, True)
camera.capture('/home/pi/Desktop/RaspAlarm/Fotos/{}.jpg'.format(fecha)) # Se toma una foto
print("Capturando foto")
time.sleep(2)
print("Copiando foto al servidor")
shutil.copy("/home/pi/Desktop/RaspAlarm/Fotos/{}.jpg".format(fecha), "/var/www/html/Fotos/{}.jpg".format(fecha)) # Se copia a la carpeta del servidor
time.sleep(1)
print("Foto guardada")
print("Enviando foto")
os.system('echo "La alarma ha sido activada. Fecha de la activacion: {0}" | mutt -s "Alguien ha abierto la puerta" [email protected] -a /home/pi/Desktop/RaspAlarm/Fotos/{1}.jpg' .format(fecha_completa, fecha)) # Se envia la foto por correo
print("Foto enviada con exito")
a = 1 # Pongo la variable en 1 para parar el proceso y que no se repita
distancia = media_distancia() # Seguimos midiento la distancia
while distancia < 10: # Pero si la distancia vuelve a ser menor de 10
break # Se termina este bucle y volvemos al principio nuevamente
But for example if I open Putty and write this if it sends the mail perfectly:
echo "La alarma ha sido activada." | mutt -s "Alguien ha abierto la puerta" [email protected]
I do not know what else to look at and try ... Thanks to everyone in advance