I have a script that send email using sendEmail (CentOS shell)
script is:
sendEmail -vvv -u "TestCompany, Inc.: USB Added" -f user@domain.com -t To@domain.com -s ASPMX.L.GOOGLE.com -m "USB Activity" -o tls=aut
o username=user3@domain.com password=password
So far this works fine.
Now i create a ConfigFile as follows:
Company=TestCompany, Inc.
FromEmail=user@domain.com
Password=password
ToEmail=To@domain.com
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.
Notice the singlequote that floated to the start of the line in the log message? Your data file probably has
\r\nfor its newlines, which doesn’t work very well on Unix; the carriage return is being read as part of the hostname. Rundos2unixon it.