.

sending attachment via sendmail with from address/name, subject and message

<<

buttErz

Newbie
Newbie

Posts: 1

Joined: Tue Apr 17, 2012 7:27 pm

Post Tue Apr 17, 2012 7:35 pm

sending attachment via sendmail with from address/name, subject and message

Hey guys, so I have been doing some reading and finally decided to come here because I am still having no luck... So I have found a way to send an attachment via sendmail but without adding a subject, from address/name, nor the message itself using this command:

uuencode filename | sendmail -fSender<senderemail@mail.com> cristi.tane@xnet.ro

However, as I said I would like to be able to add from, from name, etc, so I also found this bash script that does not work for me:

http://www.unix.com/faq-submission-queu ... ments.html

I just closed my VM for backtrack but the ONLY error I get says that it cannot find the command grep =/ while I am able to do grep outside of the script...

Finally, I also heard of a tool called MIME-tools that has everything built into it and I managed to install that successfully - but I have no idea how to use it nor can find anything readily available on google... can someone help me please? thank you! :)
<<

MaXe

User avatar

Hero Member
Hero Member

Posts: 671

Joined: Tue Aug 17, 2010 9:49 am

Post Sat Apr 21, 2012 9:15 am

Re: sending attachment via sendmail with from address/name, subject and message

Don't take this personal, but I think with a bit more searching you would've found an answered. After a couple of minutes skimming through 10-20 pages with this Google Query: "sendmail" attachment

I found the following:

How about using mutt?

mutt -a attachment -s "this is the subject" user@emailaddress.com < fileWITHdetail
or
echo "this is the detail" | mutt -a attachment -s this is the subject" user@emailaddress.com < /dev/null

Usage:
-a <file> attach a file to the message
-b <address> specify a blind carbon-copy (BCC) address
-c <address> specify a carbon-copy (CC) address
-e <command> specify a command to be executed after initialization
-f <file> specify which mailbox to read
-F <file> specify an alternate muttrc file
-H <file> specify a draft file to read header from
-i <file> specify a file which Mutt should include in the reply
-m <type> specify a default mailbox type
-n causes Mutt not to read the system Muttrc
-p recall a postponed message
-R open mailbox in read-only mode
-s <subj> specify a subject (must be in quotes if it has spaces)
-v show version and compile-time definitions
-x simulate the mailx send mode
-y select a mailbox specified in your `mailboxes' list
-z exit immediately if there are no messages in the mailbox
-Z open the first folder with new message, exit immediately if none
-h this help message


You can use mailx (which uses the Sendmail executable) command:

mailx -s "Subject Line" user@somewhere < /name/of/text_file


Reference:
http://www.unix.com/solaris/23835-attac ... dmail.html

Also see this: http://www.unix.com/shell-programming-s ... ments.html

And this: http://www.unix.com/shell-programming-scripting/58448-sendmail-attachment.html


Keep in mind that when you use premade bash scripts, make sure to edit e.g., variables that needs to be set by you.
I'm an InterN0T'er

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests

.
Powered by phpBB® Forum Software © phpBB Group.
Designed by ST Software