Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Can you send e-mail attachment using mailx

Jonathan Welbon
Occasional Visitor

Can you send e-mail attachment using mailx

From a script want to send emails with attachments out over the internet. Can the mailx utility do this. Is it possible to use the Cc and Bcc with mailx??
12 REPLIES
Bart Beeren
Advisor

Re: Can you send e-mail attachment using mailx

For sending for example text file as attachment and that it can be opened by Windows do the following:

ux2dos YourDocument|uuencode YourDocument.txt|mailx -m -s "Here is your text document" email@domain.com

(usage of cc and bcc I don't know)

BB
Life isn´t as simple as it seems
Pete Randall
Outstanding Contributor

Re: Can you send e-mail attachment using mailx

Jonathon,

This is just a sample of the hits I came up with by doing a boolean search of the forums on +mailx +attachment:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x99da35067c18d6118ff40090279cd0f9,00.html

Adding cc and/or bcc might prove just as fruitful.

Good luck,
Pete

Pete
Pete Randall
Outstanding Contributor

Re: Can you send e-mail attachment using mailx

Actually, Princess Paula's response in my previously identified thread addresses the Cc and Bcc issue, as well.

Pete

Pete
Sanjay_6
Honored Contributor

Re: Can you send e-mail attachment using mailx

Hi,

Just do a search on the forum for the solution you are looking for and you'll have the solution in no time at all.

Hope this helps.

Regds
Jonathan Welbon
Occasional Visitor

Re: Can you send e-mail attachment using mailx

Thank You very much Bart. You have opened a door I could biegin to open......but.....

All of the emails are empty. I want to send attachment but I also want some information in the email itself.

Attached is my script I am testing....
Uday_S_Ankolekar
Honored Contributor

Re: Can you send e-mail attachment using mailx

Hello,
uuencode filename filename | | sendmail emailid. or mailx mailx mailid

ex:

uuencode /etc/passwd passwd.hostname | sendmail user@domain

-USA..
Good Luck..
Christophe MAILHE
Frequent Advisor

Re: Can you send e-mail attachment using mailx

If you want to send the file as attachement and not as part of the email, you need to use MIME.

I have attached a sample script I use to send text file as attachment.

Just replace "yourservername" by the hostname of your server and "yourcompany.com" by your domain name.

Chris.
Dave La Mar
Honored Contributor

Re: Can you send e-mail attachment using mailx

Sorry you do not seem to have the answer you wish.
As I read this, you wish to send an email with an attachment and a message in the body.
If so, this should do it -

mailx -m -s "Some Title" someone@somewhere.com << EOF
`ux2dos some.fil | uuencode somefile.txt`

Type some message here for the body.

EOF


Best of Luck,
dl
"I'm not dumb. I just have a command of thoroughly useless information."
A. Clay Stephenson
Acclaimed Contributor

Re: Can you send e-mail attachment using mailx

One of the easist tolls is elm from the command line especially if you are sendiing multiple attachments and text.

Within the body of your email add this:

------------------------------------

This is my text. How are you?


[include /tmp/myattach application/octet-stream base64]

This is some more text in the middle.

[include /tmp/myexcel.xls application/ms-excel base64]

This is a closing message in the email.

----------------------------------------



That will attach /tmp/myattach and /tmp/myexcel.xls. You can include multiple attachments using this method.


Then to use it from a script:
elm -s "My Subject" dumbo@mailserver.com < myletter

Where myletter contains the attachment include statement as well as your message text. It is also necessary that you have a .elm directory
under the senders home directory because unlike the interactive version of elm the command-line version will not create a .elm directory automatically.

If it ain't broke, I can fix that.
Ronald Cogen
Frequent Advisor

Re: Can you send e-mail attachment using mailx

Hi,

/usr/bin/mailx -s "$LOCALHOST ...title ..." receiver@xxx.xx < /dir/file.dat

Make sure that your /etc/sendmail.cf has the appropriate parameters.

Regards,
Ron
I've been down so long it looks like up to me
Chua Wen Ching
Regular Advisor

Re: Can you send e-mail attachment using mailx

I think you just type:
mailx abc@hotmail.com < file.txt.

You can enter whatever email and file you want. :D

Cc and Bc i never try before.

From,
Chua Wen Ching :D
wenching
Steven E. Protter
Exalted Contributor

Re: Can you send e-mail attachment using mailx

Here is a sendmail script that can do it.

I'm hoping you are flexible on which mail utility to use. sendmail handles attachments better.

I got this straight out of an hp forum but could not find the post.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com