Cannot associate a name with uid 1234 - linux

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

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

How send email with name with third party domain?

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

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

shell to send send output as attachment to email

I dont know what is wrong with this script. I am not getting any error and I am not getting this email as well.
Code:
#!/bin/ksh
# -----------------------------------------------------------------------
# Filename: mailx.ksh
# Purpose: Demonstrates how one can attach files when sending E-Mail
# messages from the Unix mailx utility.
# Author: Frank Naude, Oracle FAQ
# -----------------------------------------------------------------------
SUBJECT="Send mail from Unix with file attachments"
TO=abcd#gmail.com
SPOOLFILE=/home/abcd/test_mail/sqlplus_test.txt
-- sql part ---
echo "Produce listing from SQL*Plus..."
sqlplus -s abcd/xxxxx >$SPOOLFILE <<-EOF
set echo off feed off veri off pages 0 head off
select count(*) from abcd;
exit;
EOF
-- send email with attachment
echo -e "This email has a attachments" | mutt -a "${SPOOLFILE}" -s "This is a test email with attachment" -- abcd#gmail.com <<-EOF
Hi,
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix mailx utility.
Best regards
~.
EOF

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.

Resources