Mailx Command Attempts to Send mail to Server/Node

60 views Asked by At

I am new to using BASH/Shell scripts and am trying to learn the best I can and have run into a small inconvience when using the mailx command.

Currently I use mailx command to send an email with attached CSV file once the process is complete. I use "-r" to set the from box as our groups email from Outlook

-r [email protected]

This works fine and the email goes out and says it's from the team box. One thing that happens is we also get an undeliverable message in our box as it appears to be trying to send one to the server the mailx is on

Unable to send mail. Message from host node.server.example.com. Then it shows the email as:
[email protected]

Since the company controls the servers and environment I can make no changes to the settings or anything like that. But is there anything I can do that will stop us from having our mailbox being cluttered up with all of the undeliverable messages?

Current mail command I am using:

echo "This is the body of the email.  There is stuff here.
Thank you for reading this.
Team Member" | mailx -r [email protected] -s "Email Subject" -a "filename.csv" - [email protected] [email protected] [email protected]
1

There are 1 answers

0
Sotark On

Thanks to John above I was able to fix this issue. Mailx was reading the - before the email addresses as a user name on the server and trying to send to [email protected]. I have removed the - and tested a few different jobs and I no longer receive the error emails.