1837981 Members
1866 Online
110124 Solutions
New Discussion

Send e-mail

 
SOLVED
Go to solution
Vogra
Regular Advisor

Send e-mail

Hi All!

I have to send e-mail from Unix box with the following characteristics:

Send Sender e-mail
Send Subject
Send an atached file

I tried a lot of solution that I get here:
Send with mailx, mail, sendmail, elm...
1) cat file.txt|mailx -r me@mydomain.com -s Subject to@yourdomain.com.br
but this solution send a plain text, not atached file.

2)/usr/bin/awk '{print $0 "\r"}' file.txt | /usr/bin/uuencode file.txt | mail you@yourdomain.com
but it don't send subject or sender name|e-mail that I want to set.

Any idea
Thanx in advance,
Lima.
We are spirits in the material world
4 REPLIES 4
Patrick Wallek
Honored Contributor
Solution

Re: Send e-mail

Here is what I use regularly and it works quite well.

The following is a single LONG command line:

(echo "Subject: Whatever" ; echo "From: from@somewhere.com" ; uuencode /filename /filename) | /usr/sbin/sendmail to@somewhere.com
Abdul Rahiman
Esteemed Contributor

Re: Send e-mail

Try this one, works for me..

# uuencode file.txt file.txt | mailx -r me@mydomain.com -s "mysbuject" to@urdomain.com

HTH,
Abdul.
No unix, no fun
someone_4
Honored Contributor

Re: Send e-mail

Hello Lima,

PART1:

Here is what I use.
The basic lay out of a file that you would send looks like so.

more mailfile

From: Someone@somewhere.net
To: otherperson@otherplace.com
Subject: test subject

this is the data



if the mailfile is created all you have to do to send it is

cat mailfile | sendmail -t

that will send the email considering that a mail relay is setup properly.


PART 2:

How to create the mailfile.
For my needs the mail file is created in a script that gathers data daily and then will email it to me so the data is always different.

In this example the datafile is the output from a script. The mailfile alwayas has to go first otherwise sendmail will not know where to send the email to. And the data file will be in the subject line.

Here is the mail send part of my script.

echo "From: you@somewhere.com " >> mailfile
echo "To: someone@somewhere.com " >> mailfile
echo "Subject: Your subject here " >> mailfile
echo " " >> mailfile
###############
cat mailfile datafile | sendmail -t



Hope this helps

Richard






Vogra
Regular Advisor

Re: Send e-mail

Hi Patrick,
your solution is ok. Thanx, but why it don't send "to" name when it is open?
Who receive it, don't know for who is sent it e-mail. It is not a problem, I only curious.
Thanx a lot,
Lima.

Abdul, your solution try to send file sile.txt in plain text (already codificated) in my unix box. Any idea? Thanx anyway.

Richard, you solution don't send attached file. Thanx anyway.

Thanx to all!
Lima.
We are spirits in the material world