3 ms·
I would actually do it with an SMS like this. $ cat /bin/awkmail #!/bin/gawk -f BEGIN { smtp="/inet/tcp/0/smtp.yourISP.com/25"; ORS="\r\n"; r=ARGV[1];
by chasil 4y ago
I would actually do it with an SMS like this.
$ cat /bin/awkmail
#!/bin/gawk -f
BEGIN { smtp="/inet/tcp/0/smtp.yourISP.com/25";
ORS="\r\n"; r=ARGV[1]; s=ARGV[2]; sbj=ARGV[3]; # /bin/awkmail to from subj < in
print "helo " ENVIRON["HOSTNAME"] |& smtp; smtp |& getline j; print j
print "mail from:" s |& smtp; smtp |& getline j; print j
if(match(r, ","))
{
split(r, z, ",")
for(y in z) { print "rcpt to:" z[y] |& smtp; smtp |& getline j; print j
}
}
else { print "rcpt to:" r |& smtp; smtp |& getline j; print j }
print "data" |& smtp; smtp |& getline j; print j
print "From: " s |& smtp; ARGV[2] = "" # not a file
print "To: " r |& smtp; ARGV[1] = "" # not a file
if(length(sbj)) { print "Subject: " sbj |& smtp; ARGV[3] = "" } # not a file
print "" |& smtp
while(getline > 0) print |& smtp
print "." |& smtp; smtp |& getline j; print j
print "quit" |& smtp; smtp |& getline j; print j
close(smtp) } # /inet/protocol/local-port/remote-host/remote-port
$ echo ricki dont lose that number | awkmail 9998675309@vtext.com me@here.com test
- rsync 4y agoOne issue with carrier email-to-sms gateways is that they truncate messages at a relatively short number of characters. Twilio SMS API, on the other hand, does not have that limit and you can send long SMS messages with a single 'curl' command: /usr/local/bin/curl -s -X POST -d "Body=$msg" -d "From=$from" -d "To=$to" "https://api.twilio.com/2010-04-01/Accounts/$accountsid/Messages" -u "$accountsid:$authtoken" That's simplified - I actually pipeline through 'tidy5' and 'source-highlight' to make the output pleasing: /usr/local/bin/curl -s -X POST -d "Body=$msg" -d "From=$from" -d "To=$to" "https://api.twilio.com/2010-04-01/Accounts/$accountsid/Messages" -u "$accountsid:$authtoken" | tidy5 -xml -iq | source-highlight -s xml -f esc | awk 'xor(/TwilioResponse/,/Message/,/To/,/From/,/Body/,/Status/,/ErrorCode/,/ErrorMessage/)' | grep -v "/2010-04-01/Accounts/"