7012 questions

8392 answers

13629 comments

10306 members

0 votes
66 views 0 comments
by
Hello !

I would like to add this command as a custom script :

echo "Router was restarted" | mail -s "Restart" jonhny@gmail.com

How to do this ? As I checked, "mail" command is unavaible.

Best,

Adam

1 Answer

0 votes
by

Hi,

There's a command that you could use with emails, I'll put it here in the form of the script file.

#!/bin/sh

echo -e "subject:test\nfrom:testmail@gmail.com\n\ntestestestestest" | sendmail -v -H "exec openssl s_client -quiet -connect smtp.gmail.com:587 -tls1 -starttls smtp" -f testmail@gmail.com -au"testmail@gmail.com" -ap"lalalal" recipient@gmail.com

Just make sure you have third-party app access and other SMTP settings enabled in Gmail before executing this with your emails.

EB.