3

Hi i've a problem whit this code:

# up here there's more code

echo "Password changed" $(date) > lez.txt
curl -n --ssl-reqd --mail-from "[email protected]" --mail-rcpt "my mail" -T lez.txt --url smtps://smtp.gmail.com:465 --user "[email protected]:password"

If I run the script I get only a empty mail, but if I do this manually I get my mail. Thanks.

1

2 Answers 2

5

It looks like it's having problems to find the file contents. What about using a here-string to avoid writing a file at all? Change your code to:

curl -n --ssl-reqd --mail-from "[email protected]" --mail-rcpt "my mail" -T - --url smtps://smtp.gmail.com:465 --user "[email protected]:password" <<<"Password changed $(date)"

Notice the echo statement removal, the here-string at the end of the line and the -T - to get the file from stdin.

Sign up to request clarification or add additional context in comments.

Comments

0

cURL expects that the file to be sent has a empty line on the 1st row

the script below will do that for you

##!/bin/sh
# USAGE 
#
# sh emailfile.sh examplefile.log


file="$1"
echo "" > temp | cat "$1" >> temp && mv temp "$1"

wait

curl --url "smtps://smtp.mail.yahoo.com:465" \
     --mail-from "[email protected]" \
     --mail-rcpt "[email protected]" \
     --user "[email protected]:EmailAccountPassword" \
     -T - --silent < "$file"

wait

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.