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 ?>
Please enter your email address and I will send you a copy of my resume ASAP.
add_attachment($data, $filename, $content_type); # send e-mail $mail->send(); break; case "msword": $filename="swerdloff.resume.docx"; $fd=fopen($filename, "r"); $data=fread($fd, filesize($filename)); fclose($fd); $content_type="application/msword"; $result="Microsoft Word"; $mail = new mime_mail; $mail->from = "jonathan@swerdloff.com"; $mail->to = $recipient; $mail->subject = "Resume of Jonathan Swerdloff"; $mail->body = "Thank you for your interest in my resume. Please let me know if you have any comments, questions, or would like any more information."; $mail->add_attachment($data, $filename, $content_type); $mail->send(); #output $ipaddress = $_SERVER["REMOTE_ADDR"]; $output2="I sent $recipient a copy of my resume.

"; print "
$output2"; print "Thank you for your interest. Please note - if you are a gmail user and you do not receive a copy of my resume, please check the updates tab.
"; #send the follow-up email $mail2 = new mime_mail; $mail2->from = "jonathan@swerdloff.com"; $mail2->to = "jonathan.swerdloff@gmail.com"; $mail2->subject = "Resume requested!"; $mail2->body = "$output2"; $mail2->send(); break; case "ascii": $filename="swerdresume.txt"; $fd=fopen($filename, "r"); $data=fread($fd, filesize($filename)); fclose($fd); $content_type="text/plain"; $result="plain text"; mail ($recipient, "Resume of Jonathan Swerdloff", $data, "From: jonathan@swerdloff.com\n"); break; } $datestamp = date("Y-m-d H:i:s",time()); $fp = fopen("resume.log","a+"); fwrite($fp, "DATE: $datestamp - "); fputs($fp,"$output2 via $ipaddress \n"); fclose($fp); #confirmation ?>