0

I have a script that send email using sendEmail (CentOS shell) script is:

sendEmail -vvv -u "TestCompany, Inc.: USB Added" -f [email protected] -t [email protected] -s ASPMX.L.GOOGLE.com -m "USB Activity" -o tls=aut
o [email protected] password=password

So far this works fine.

Now i create a ConfigFile as follows:

Company=TestCompany, Inc.
[email protected]
Password=password
[email protected]
Smtp=ASPMX.L.GOOGLE.com

and Now I modify my script as follow:

#!/bin/sh
i=1;
while IFS="=" read VAR VALUE
do
        VAR="${VAR// }"
        Values[$i]=${VALUE}
        let i++;
done <  ConfigFile

sendEmail -vvv -u "${Values[1]}: USB Added" -f ${Values[2]} -t ${Values[4]} -s ${Values[5]} -m "Test Email" -o tls=auto username=${Values[2
]} password=${Values[3]}

I get following error:

'25 failed: IO::Socket::INET: Bad hostname 'ASPMX.L.GOOGLE.comempt to ASPMX.L.GOOGLE.com
Apr 21 12:11:35 box2 sendEmail[26378]: HINT => Try specifying a different mail relay with the -s option.

Now I'm unable to understand that why I'm getting this error. even when i try to echo Values it shows me correct values. then where I'm doing wrong.? Please help. thanks.

1 Answer 1

2

Notice the singlequote that floated to the start of the line in the log message? Your data file probably has \r\n for its newlines, which doesn't work very well on Unix; the carriage return is being read as part of the hostname. Run dos2unix on it.

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

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.