Solved

Send File from Webpage as MIME attatchment

Posted on 1997-02-24
3
261 Views
Last Modified: 2013-12-25
I need a script that sends a user defined file in a mail, as a attatchment, from a form on a webpage an adress free of
choice.

For an exempel:

             Welcome to "virtual postcard"

             Your E-mail:
             Recivers E-mail:
             choose one off the pictures:
             Picture1 Picture2 Picture3
               ( ) ( ) ( )
             [Submit]

Now an E-mail should be sent to "reciver" whith
an text (same for all pictures), and the choosen
picture.
IT is Important that the attatchment is in the MIME format..
             
Technical Things

* I'm using an linux server
* I'm able to run my own scripts
/Jonas
0
Comment
Question by:nifer
  • 2
3 Comments
 

Author Comment

by:nifer
ID: 1827629
Adjusted points to 70
0
 
LVL 1

Accepted Solution

by:
Kallisti earned 70 total points
ID: 1827630
Uhh, got the other one put through as a good answer,
despite it not being 100%..  Feel free to reject/delete
on this one, but I have altered the script so that it
creates a mime-email...

A quick point about it is that it is possible that your
uuencode program does not support base64.  This is
required for MIME, however, if it does not, altering
the base64 line to uuencoded, and remove the -m arg
from uuencode.

#!/bin/sh
#
# No (c), no warantee, no payment required, NOT MY FAULT.
# Bugs: I have not bothered to check ANYTHING bar the sendmail
# This will mail to any address, etc.. needs to be more paranoid.

SENDMAIL="/usr/sbin/sendmail"
# Ensure that is correct!

EMAILADDR=`echo $QUERY_STRING | cut -d\& -f1 | cut -d\= -f2`
PICTURE=`echo $QUERY_STRING | cut -d\& -f2 | cut -d\= -f2`

echo "Content-type: text/html"
echo
echo "<HTML><TITLE>On it's way</TITLE>"
echo "<H1>Its been mailed!</H1>"
echo "Mailed $PICTURE to $EMAILADDR"
echo "</HTML>"

$SENDMAIL $EMAILADDR << EOF
Reply-To: webmaster\@$HTTP_HOST
From: picserver\@$HTTP_HOST
To: $EMAILADDR
MIME-Version: 1.0
Subject: Requested Picture
Content-Type: multipart/mixed;
              boundary=unique-boundary-1

This is the preamble area of a multipart message.
Mail readers that understand multipart format
should ignore this preamble.

If you are reading this text, you might want to
consider changing to a mail reader that understands
how to properly display multipart messages.

--unique-boundary-1

This is the text that describes what the mail
is about to the person who recieved it.

--unique-boundary-1
Content-Type: image/gif
Content-Transfer-Encoding: base64

`uuencode -m $PICTURE $PICTURE`

--unique-boundary-1--
EOF

0
 

Author Comment

by:nifer
ID: 1827631
Sorry only Mime is accepteble
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now