How send email with name with third party domain? - linux

Is it possible to send email with address name with third party domain?
For example to send email with address name: my_email#google.com using Linux environment?

mailx utility can do this. Below is the example:
Suppose CONTENT is a variable storing the content.
echo $CONTENT | mailx -r FROM_EMAIL_ID -s "SUBJECT" TO_EMAIL_ID
Else, you want to pass a file having mail body named CONTENT.txt,
mailx -r FROM_EMAIL_ID -s "SUBJECT" TO_EMAIL_ID < CONTENT.txt

Related

Shell script to send email is not working from Informatica

I have a very simple script
echo "Test email body" | mailx -s "Subject" vinay#informatica.com
When I run the script from linux, it's working fine and I'm receiving the email
But, when I use the same script in post session success command or command task in informatica, the script is successful but I did not receive the mail
Also, without calling the script, I directly gave the mail command in post session success command
echo "Test email body" | mailx -s "Subject" vinay#informatica.com
Still, it's not working.
Can someone help me on this.
touch email.txt > you message
cat /tmp/email.txt
Subject: Terminal Email Send
Email Content line 1
Email Content line 2

Linux shell emailing - set sender address using "mail" command

I am using the "mail" command in Linux shell to send an email when programmatically prompted to do so. I am using
mail -s 'subject' recipient#theirhost.com <<< 'Email body'
to send it at present, but this does not include a sender address. Instead, the system uses the account name as the sender address. I've seen the claim that "-aFrom:myname#myhost.com" should work, but -a is being interpreted as an attachment attempt, not a header change. This results in the error: "From:Mynamemyname#myhost.com: No such file or directory". I've also seen a claim that this works:
-r "from#fromserver.com"
But the OS doesn't even know what that means, in my case.
Is there a way to make this work without additional software? I don't need a from name, but a from address would be very helpful.
Note: let's consider ssmtp, mutt, and other such add-on software unavailable. Attempting to install and use such software would be problematic.
Thank you!
Edit 1: I'm not certain how to check what version of "mail" I have. With some difficulty, I got it to spit out the usage, which is as follows.
-T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
Never mind, I got it. "-r" can actually work.
I successfully used:
echo "This is the message body" | mail -s "This is the Subject" -r "FromName<fromAddress#example.com>" recipientName#example.com
It looks like karakfa was onto something also, as I do have mailx available to me also, but it looks like I won't be needing that for this use case.
Thank you!

Linux mail command to bcc multiple addresses?

I am using linux mail command to send an automated email to a bunch of people once per week.
I want each one of the recipients to be BCC'ed.
I am trying this command:
mail -v -s "Email Subject" -b george#gmail.com, maria#email.com, gina#correo.com, asher#texting.com -- -f jpatino#azucarcolombia.com < /pathTo/dir/emailText.txt
But get this error:
You must specify direct recipients with -s, -c, or -b.
you need to put them all in a single argument by quoting it.
mail -v -s "Email Subject" -b 'george#gmail.com, maria#email.com, gina#correo.com, asher#texting.com' -- -f jpatino#azucarcolombia.com < /pathTo/dir/emailText.txt
It seems there are multiple versions of the mail command.
mail (GNU Mailutils) 3.7 has an append option to add headers and values directly without piping them in. Just add the headers you need there, e.g. bcc:
echo "Just testing my sendmail" | mail -s "Sendmail test" test#to.com --append=Bcc:test#bcc.com,other#bcc.com
How to send mail through BCC in UNIX

crontab mutt email fails to be sent

I have a crontab which is supposed to send an email, but it doesn't.
echo " ok backup " > /home/nuvoshift01/zDB-backup-start.txt
mysqldump --opt --user=q --password=xyz --host=localhost giladparking > /home/nuvoshift01/GPmonthly-DBdump.sql
mutt me#gmail.com -s "MySQL BackUp" -a /home/nuvoshift01/GPmonthly-DBdump.sql < /home/nuvoshift01/zDB-backup-start.txt > /home/nuvoshift01/whatHappened.txt
touch /home/nuvoshift01/zDB-bacup-end.txt
(1) the first line does touch the file as coded
(2) the back up file is created
(3) the mutt mail does not send
(4) the 4th line does touch the file as coded
if I issue the mutt command from the command the email IS sent with the attachment
my puzzle/question is: why doesn't the email get sent by the crontab?
OK, today I provide the solution to my own problem. I determined to send the email with mutt I needed to create a properly configured .muttrc file AND explicitly describe the path in the cron task.
my .muttrc file looks like this :
set from = "anyaddress#anydomain.com"
set hostname = hostname.com
set envelope_from = yes
the mutt command needs to look like this:
mutt -F /home/user/.muttrc -s "SUBJECT" any#address.com -a /home/user/attachedfile.txt < /home/user/bodyofmessage.txt
It turns out the message will likely end up in the spam folder of the recipient.
A special thank you for Major Hayden at Rack Space for his assistance behind the scenes.

Cannot associate a name with uid 1234

How would one send a mail from a batch script using a virtual user (uid number is not present in /etc/passwd) ?
Currently it keeps on failing with:
$ mail -s "my subject" foobar#example.com
Cannot associate a name with uid 1234
You can call sendmail directly. Just build out the complete email message including headers, and then send it through sendmail -t. the -t tells sendmail to read the headers from the message itself for the required information.
---start of mail.txt---
date: now
to: foobar#example.com
subject: My Subject
from: your-email#example.com
body of message.....
---end of mail.txt----
then
/usr/sbin/sendmail -t < mail.txt
or you can just open a pipe , and echo the contents of the message into the pipe
| /usr/sbin/sendmail -t

Resources