Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 135,948 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,719 people online right now. Registration is fast and FREE... Join Now!




Ps Mail!

 
Reply to this topicStart new topic

Ps Mail!

Dr. Tim
14 Sep, 2002 - 05:06 PM
Post #1

D.I.C Addict
****

Joined: 20 Mar, 2002
Posts: 993

http://ps.flashages.com/pscomp.php

It's pretty cool, and doesnt use the mail() function, but real mailing... stuff. I am planning on integrating it into PS's Welcome Home area. Any bugs?!
User is offlineProfile CardPM
+Quote Post

objekt404
RE: Ps Mail!
14 Sep, 2002 - 10:03 PM
Post #2

Whiskey Tango Foxtrot!?
*****

Joined: 15 Apr, 2001
Posts: 1,568

QUOTE(FlashAges @ Sep 14 2002, 09:06 PM)
http://ps.flashages.com/pscomp.php

It's pretty cool, and doesnt use the mail() function, but real mailing... stuff. I am planning on integrating it into PS's Welcome Home area. Any bugs?!

Um, not to troll or anything, but how is that different from CDO.Mail for ASP? Looks like about 8 lines in ASP.

Really, I am curious...
User is offlineProfile CardPM
+Quote Post

Dr. Tim
RE: Ps Mail!
15 Sep, 2002 - 09:04 AM
Post #3

D.I.C Addict
****

Joined: 20 Mar, 2002
Posts: 993

CODE
<?

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";
  }

  /*
   *      string get_mail()
   *      returns the constructed mail
   */

  function get_mail($complete = true) {
     $mime =  "";
     if (!empty($this->from))
        $mime .=  "From: ".$this->from. "\n";
     if (!empty($this->headers))
        $mime .= $this->headers. "\n";

     if ($complete) {
        if (!empty($this->to)) {
           $mime .= "To: $this->to\n";
        }
        if (!empty($this->subject)) {
           $mime .= "Subject: $this->subject\n";
        }
     }

     if (!empty($this->body))
        $this->add_attachment($this->body,  "",  "text/plain");
     $mime .=  "MIME-Version: 1.0\n".$this->build_multipart();

     return $mime;
  }

  /*
   *      void send()
   *      Send the mail (last class-function to be called)
   */

  function send() {
     $mime = $this->get_mail(false);
     mail($this->to, $this->subject,  "", $mime);
  }
};  // end of class

?>

User is offlineProfile CardPM
+Quote Post

Dr. Tim
RE: Ps Mail!
15 Sep, 2002 - 09:05 AM
Post #4

D.I.C Addict
****

Joined: 20 Mar, 2002
Posts: 993

Not exactly 8 lines... :\
User is offlineProfile CardPM
+Quote Post

Cookie Mobster
RE: Ps Mail!
15 Sep, 2002 - 09:48 AM
Post #5

nooneenooneenooonee
Group Icon

Joined: 12 Oct, 2001
Posts: 4,723


Dream Kudos: 18
My Contributions
QUOTE(FlashAges @ Sep 14 2002, 06:06 PM)
It's pretty cool, and doesnt use the mail() function, but real mailing...

What the heck is this line then?

CODE

mail($this->to, $this->subject,  "", $mime);

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 09:00AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month