phpbar.de logo

Mailinglisten-Archive

[php] eMails mit Attachement verschicken?

[php] eMails mit Attachement verschicken?

TICINONLINE info_(at)_ticinonline.to
Wed, 13 Oct 1999 03:32:48 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_015B_01BF152B.9EC12BA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Mailafile.php3


besser auf 2 file aufteilen  :-)

Zum testen http://www.ticinonline.to/search/guestbook/mailafile.php3
"MAX_FILE_SIZE" value="5000000"

mit cookie damit man nicht immer neu den absender reinschreiben muss

Die loesch funktion sollte noch aktiviert werden :-( ansonsten KB ueber KB
haufen)

Mit freundlichen Gruessen
Cordiali Saluti

Peter Hohl
====================================
PPK ScreenDesign www & CD
Mysql Data sheet (Banca dati Dinamiche)
CGI Program Perl & PHP3
DHTML JAVA
6672 Gordevio
Tel: 091/7532066
Fax: 091/ 7532069
info_(at)_ti-news.ch
info_(at)_ticinonline.to
http://www.ti-news.ch/  Ti Search oltre 900 recensioni con Ti Mail sembre
raggiungibili
http://www.ticinonline.to/  Die neue Tessiner Suchmachine
====================================







----- Original Message -----
From: Martin <martin_(at)_cheabit.com>
To: <php_(at)_solix.wiso.Uni-Koeln.DE>
Sent: Tuesday, October 12, 1999 9:39 PM
Subject: [php] eMails mit Attachement verschicken?


> Hallo,
>
> als Neueinsteiger in Sachen PHP nun mal eine Frage von mir:
>
> Kennt jemand von euch eine Möglichkeit, einem Interessenten per
> eMail eine Datei (z.B. ZIP-Datei) anzuhängen?
>
> Bei CGI bin ich bis jetzt immer verzweifelt. Vielleicht gibts ja diese
> Möglichkeit bei PHP?
>
> In meinem Falle möchten immer mehr Interessenten unsere Dateien
> per eMail zugeschickt haben, doch bisher habe ich keine geeignete
> Möglichkeit gefunden dise zu realisieren.
>
> Für jegliche Tips wäre ich dankbar.
>
> Schöne Grüsse und schon mal besten Dank!
>
> Martin Geisler
> ----
> http://www.cheabit.com
> http://www.w-e-b-h-o-s-t-i-n-g.de - http://www.tele-fon.de
>
> --
> ** Durchgehend geöffnet: http://www.php-center.de **
> Die PHP-Liste: mailto:php_(at)_infosoc.uni-koeln.de
> http://infosoc.uni-koeln.de/mailman/listinfo/php

------=_NextPart_000_015B_01BF152B.9EC12BA0
Content-Type: application/octet-stream;
	name="mailafile.php3"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="mailafile.php3"

<?

/*
 *  Cookie From Mark Kronebein
 *  Guestbook Version 8
=20
 */

if(empty($tisName))
{
setcookie( "tisName", $name, time()+99999999);
$tisName=3D$name;
}

if(empty($tisEmail))
{
setcookie( "tisEmail", $email, time()+99999999);
$tisEmail=3D$email;
}

/*
 *  Class mime_mail
 *  Original implementation by Sascha Schumann <sas_(at)_schell.de>
 *  Modified by Tobias Ratschiller <tobias_(at)_dnet.it>:
 *  and remodifiet by Patrik info_(at)_ticinonline.to the swiss search engime =
www.ticinonline.to
 *      - General code clean-up
 *      - separate body- and from-property
 *      - killed some mostly un-necessary stuff
 */
=20
class mime_mail=20
 {
 var $parts;
 var $to;
 var $from;
 var $headers;
 var $subject;
 var $body;


 function mime_mail()
  {
  $this->parts =3D array();
  $this->to =3D "";
  $this->from =3D "";
  $this->subject =3D "";
  $this->body =3D "";
  $this->headers =3D "";
  }


 function add_attachment($message, $name =3D "", $ctype =3D =
"application/octet-stream")
  {
  $this->parts[] =3D array (
                          "ctype" =3D> $ctype,
                          "message" =3D> $message,
                          "encode" =3D> $encode,
                          "name" =3D> $name
                          );
  }

/*
 *      void build_message(array part=3D
 *      Build message parts of an multipart mail
 */
function build_message($part)
 {
 $message =3D $part["message"];
 $message =3D chunk_split(base64_encode($message));
 $encoding =3D "base64";
 return "Content-Type: ".$part["ctype"].
                        ($part["name"]?"; name =3D =
\"".$part["name"]."\"" : "").
                        "\nContent-Transfer-Encoding: =
$encoding\n\n$message\n";
 }

/*
 *      void build_multipart()
 *      Build a multipart mail
 */
function build_multipart()=20
 {
 $boundary =3D "b".md5(uniqid(time()));
 $multipart =3D "Content-Type: multipart/mixed; boundary =3D =
$boundary\n\nThis is a MIME encoded message.\n\n--$boundary";

 for($i =3D sizeof($this->parts)-1; $i >=3D 0; $i--)=20
    {
    $multipart .=3D =
"\n".$this->build_message($this->parts[$i])."--$boundary";
    }
 return $multipart.=3D "--\n";
 }

/*
 *      void send()
 *      Send the mail (last class-function to be called)
 */
function send()=20
 {
 $mime =3D "";
 if (!empty($this->from))
    $mime .=3D "From: ".$this->from."\n";
 if (!empty($this->headers))
    $mime .=3D $this->headers."\n";
   =20
 if (!empty($this->body))
    $this->add_attachment($this->body, "", "text/plain");  =20
 $mime .=3D "MIME-Version: 1.0\n".$this->build_multipart();
 mail($this->to, $this->subject, "", $mime);
 }
};=20






$submit=3D SEND;
$ip1 =3D getenv("REMOTE_ADDR");
$ip =3D gethostbyaddr($ip1);

echo"<FORM ENCTYPE=3D\"multipart/form-data\" NAME=3DMyForm =
ACTION=3D$PHP_SELF METHOD=3D\"POST\">";
echo"<table ALIGN=3D\"center\" WIDTH=3D\"80%\"><tr>";
echo"<td><h1>Mail a File</h1>";
echo"From Name:<br><input type=3D\"text\" name=3D\"name\" size=3D50 =
value=3D\"$tisName\"><br>";
echo"From E-Mail <br><input type=3D\"text\" name=3D\"email\" size=3D50 =
"; =20
echo"value=3D\"$tisEmail\"><br>";
echo"TO E-Mail:<br><input type=3D\"Hidden\" name=3D\"sendmail\" =
value=3D\"yes\">";
echo"<input type=3D\"text\" name=3D\"tomeil\" size=3D50><br>";
echo"Subjekt:<br><input type=3D\"text\" name=3D\"betreff\" =
size=3D50><br>Text:<br><textarea name=3D\"kommentar\" rows=3D\"7\" =
cols=3D\"50\" wrap=3Dphysical></textarea><br>Attachment:<BR><INPUT =
TYPE=3D\"hidden\" name=3D\"MAX_FILE_SIZE\" value=3D\"5000000\"><INPUT =
NAME=3D\"MyFile\" TYPE=3D\"File\"><br><hr>";
echo"<input TYPE=3D\"submit\" name=3D\"action\" =
VALUE=3D\"$submit\"><br>";
echo"</FORM></td></tr>";
echo"</table>";


if($action =3D=3D "$submit"){=20
print "Send to $tomeil <a href=3D\"$PHP_SELF\">Back</a>";

if($MyFile !=3D "none") {
// wo Ihn stellen ?
copy($MyFile,"/pic/$MyFile_name");
}
}
if ($sendmail =3D=3D "yes"){


 $attachment =3D fread(fopen("pic/$MyFile_name", "r"), =
filesize("pic/$MyFile_name"));=20

 $mail =3D new mime_mail();
 $mail->from =3D "$email";
 $mail->headers =3D "Errors-To: info_(at)_microsoft.com";
 $mail->to =3D "$tomeil";
 $mail->subject =3D "$betreff";
 $mail->body =3D "From: $name $kommentar";
 $mail->add_attachment("$attachment", "pic/$MyFile_name", "text/plain");
 $mail->send();

=20
 }





?>

------=_NextPart_000_015B_01BF152B.9EC12BA0--



php::bar PHP Wiki   -   Listenarchive