2

Im writing a script, and I want it to alert me via text message. I can send my self texts via things like gmail using: "number@vtext.com", and I can send emails to gmail using the mail command, but when I try to get my script to send me a text message, I never get it, I'm not sure why.

#!/bin/bash
set -vx
m="The cookie jar is open."
s="Give me a cookie"
id="@vtext.com"
num="0000000000"    #fake number for this post.
echo -e $m | mail -s $s  $num$id  

How can I send sms to my cellphone? what am I doing wrong?

my carrier is verison.

  • If you have your system able to send via command line setup like linode.com/docs/email/postfix/… then you might be missing quotes like echo -e "$m" | mail -s "$s" $num$id I don't think the -e is needed. I send from my scripts and I don't have the -e. – Terrance Apr 26 '18 at 13:39
  • -e was for something else not included, but I don't think it should hurt the overall functionality either. Ill give your recommendation a try, thanks or looking. – j0h Apr 26 '18 at 13:54
  • 2
    The system running this, is this on a Residential connection, or is it a dedicated server like a VPS? Most residential ISPs are 'blacklisted' for email sources, and aren't permitted to send emails out as an SMTP / Mail Origin point. (unless it's routed over GMail or a third-party server which actually handles the sending of the message to the destination 'address') – Thomas Ward Apr 26 '18 at 14:01
  • 1
    @j0h Have you tried to send something to your phone by using your GMail Web App? – Terrance Apr 26 '18 at 15:49
  • 1
    Check your /var/log/mail.log when you try to send. It might help pinpoint more of what is going on. – Terrance Apr 26 '18 at 17:47
0

If using gmail you will have to enable "less secure apps" as done here https://support.google.com/accounts/answer/6010255?hl=en

I ran across the same problem in windows using CDO.Message and had to inform gmail that I was using "less secure apps" before my text message would work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.