|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
sendmail attachment
I need to send an email with an attached .pdf file. I am able to send the attcahed file using uuencode as follows (script1) :
ATTFILE=/home/user/test.pdf ATTNAME=test.pdf MAILTO=my.receiver@xxx.com MAILFROM=my.sender@xxx.com uuencode $ATTFILE $ATTNAME | sendmail -v f${MAILFROM} ${MAILTO} This code delivers the attached file correctly to my.receiver@xxx.com, however it ends up in Spam mail with : From: my.sender@xxx.com To: Cc: Subject: Attachments : test.pdf This is doing everything I need, except putting my.receiver@xxx.com in the To: line of the email, which apparently is causing it to end up as SPAM, yet the email does end up at my.receiver@xxx.com's email. Go figure ? SO the I tried the following (script2) : ATTFILE=/home/user/test.pdf ATTNAME=test.pdf MAILTO=my.receiver@xxx.com MAILFROM=my.sender@xxx.com TEMPFILE=tempmail.txt echo"From:${MAILFROM}\nTo:{MAILTO}\nCc:\nSubject:\n" > TEMPFILE uuencode ${ATTFILE} ${ATTNAME} | sendmail -t -oi < ${TEMPFILE} This puts all of the information in the email address lines, and delivers the mail to my.receiver@xxx.com's inbox, but no attachement : From: my.sender@xxx.com To: my.receiver@xxx.com Cc: Subject: Attachments : I need to force the To: line in script1, or make the attachment work in script2. Any Ideas ? |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Do you have reason to believe that you can second-guess the recipient's spam filter, or do you know for a fact that this will solve your problem? Try filling in more of those fields; empty Subject lines trip some spam filters, too. script2 is apparently an attempt at solving this, but uses invalid syntax -- you can't both pipe to sendmail and have it read a file. See a fix below. uuencode is pretty ancient; perhaps you can find a tool which would allow you to send a proper MIME attachment. I don't think this has any bearing on the spam filtering, but a proper tool would feel a lot less crippling and give you more control over what is sent. Code:
ATTFILE=/home/user/test.pdf
ATTNAME=test.pdf
MAILTO=my.receiver@xxx.com
MAILFROM=my.sender@xxx.com
( cat <<HERE; uuencode "${ATTFILE}" "${ATTNAME}" ) | sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: attached $ATTNAME
HERE |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
scripts works fine but attachment is part of the body ?
Hi, I tried the script, but the attachment is part of the mail body, and is "non readable" (unencoded text enclosed by begin and end identifiers). I was expecting an e-mail with the text file as an attachment. What have I missed ?
I have tried several different text files. Thanks for any help :-) |
|
#4
|
|||
|
|||
|
Like I wrote above, uuencode is not a valid MIME attachment; in fact, MIME was invented in part to overcome the limited usability and modularity problems of inlining uuencoded binaries into the main mail message. The MIME framework provides a facility for messages with multiple parts ("multipart") some of which can have a content-disposition of "attachment".
Having said that, some sending programs recognize uuencode, and transform the message to MIME on the fly; and some receiving programs recognize uuencode, and display it as an attachment, even though it's technically just a blob of text inlined into the human-readable mail body. The FAQ section has several scripts for sending proper MIME attachments. The easiest is probably if you have mutt or a reasonably recent elm or pine, but if those are not an options, check out the scripts over here |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sendmail with HTML body and attachment | atelford | Shell Programming and Scripting | 8 | 09-30-2011 06:10 AM |
| sendmail attachment issue | Shahul | Shell Programming and Scripting | 4 | 03-05-2010 12:47 PM |
| sendmail attachment problem | yakari | UNIX for Dummies Questions & Answers | 1 | 07-02-2009 11:47 PM |
| Using Sendmail (& attachment) | kenkanya | UNIX for Dummies Questions & Answers | 3 | 01-19-2009 10:22 PM |
| attachment using sendmail | vastare | Solaris | 4 | 01-03-2006 11:56 AM |
|
|