Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write a simple script to send a file via email?

Status
Not open for further replies.

abrummel

Programmer
Oct 6, 2000
2
US
I want to write a script that will email a file to an external email address. I'm relatively new to UNIX, but I have a strong programming background. If anyone has any suggestions, it would be very appreciated.

thanks! [sig][/sig]
 
Firstly, is your mail service configured to send external mail and have you read the man pages for mail and sendmail?
[sig]<p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>Top man[/sig]
 
If your mail service is okay then try a line like this: -

cat file | mailx -s &quot;Message&quot; externalmailaddress

If you need a bit more info on shell scripts just shout. [sig]<p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>Top man[/sig]
 
Or try
[tt]
mail -s &quot;Subject of mail&quot; mail_address < the_plain_ascii_file
[tt]

I hope it works.. [sig][/sig]
 
hi all,

what if the file is binary and he wants to send it as an attachment.

-shail [sig][/sig]
 
Thanks to all for your suggestions.

I'm able to send an email externally.

But I want to attach a text file. I don't want the file to be the message, I want to send the text file as an attachment. How would I go about doing this?

Any suggestions would be appreciated.

thanks,

Andy

[sig][/sig]
 
Have you posted this ptoblem to the sendmail forum? [sig]<p>Ged Jones<br><a href= > </a><br>Top man[/sig]
 
Ged was right -- just that the link was wrong, have a look at this thread (it's the one ged was pointing to I think)

thread80-8604
[sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top