Announcement

Collapse
No announcement yet.

Per PHP eine Mail mit Anhang versenden ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Per PHP eine Mail mit Anhang versenden ?

    Hallo liebe Entwickler,

    bräuchte mal unbedingt einen Beispiel Quelltext für das versenden einer E-Mail mit Dateianhang, welcher im gleichen Verzeichnis wie das Script liegt.
    <br><br>
    Der normale Quellcode sieht doch so aus:<br>

    mail("[email protected]","Betreffzeile","Mailtext","From: [email protected]");

    <br><br>
    Wie und wo muss ich die Datei angeben die mit versendet werden soll ? Habe schon eine ganze Menge Script-Archive durchsucht und mächtig gegoogelt, aber irgendwie nichts brauchbares gefunden.

    Vielen Dank im vorraus!<br>
    Keptn_Kirk

  • #2
    ich hab das auch schon gemacht. hab das script aber verlegt. weiss nur noch, daß das über ne Class gelöst wurde. Wenn ich das script finde, meld ich mich noch mal. den teil hab ich schon. vielleicht kannst du ja damit was anfangen:<br><br><PRE>class mime_mail
    {
    var $parts;
    var $to;
    var $from;
    var $headers;
    var $subject;
    var $body;

    /*
    * void mime_mail()
    * class constructor
    */
    function mime_mail()
    {
    $this->parts = array();
    $this->to = "";
    $this->from = "";
    $this->subject = "";
    $this->body = "";
    $this->headers = "";
    }

    /*
    * void add_attachment(string message, [string name], [string ctype])
    * Add an attachment to the mail object
    */
    function add_attachment($message, $name = "", $ctype = "application/octet-stream")
    {
    $this->parts[] = array (
    "ctype" => $ctype,
    "message" => $message,
    "encode" => $encode,
    "name" => $name
    );
    }

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

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

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

    /*
    * void send()
    * Send the mail (last class-function to be called)
    */
    function send()
    {
    $mime = "";
    if (!empty($this->from))
    $mime .= "From: ".$this->from. "\n";
    if (!empty($this->headers))
    $mime .= $this->headers. "\n";

    if (!empty($this->body))
    $this->add_attachment($this->body, "", "text/html");
    $mime .= "MIME-Version: 1.0\n".$this->build_multipart();
    mail($this->to, $this->subject, "", $mime);
    }
    }; // end of class
    </pre>
    <br>cu Marcu

    Comment


    • #3
      Super danke dir und schau mir das mal in Ruhe bei einer riesen großen Tasse Kaffee an!

      Greets Keptn_Kir

      Comment

      Working...
      X