op het web heb ik een script gevonden waarmee ik emailtjes kan versturen met attachments.
Alleen als ik het script draai krijg ik de volgende warning:
Ik ben nog maar een PHP-newbie en snap van het script niet echt veel. Ik hoop dat jullie de fout kunnen zien.
Warning: Bad Message destination in c:\apache\htdocs\test\test1.php on line 103
Ik gebruik het volgende script
Alleen als ik het script draai krijg ik de volgende warning:
Ik ben nog maar een PHP-newbie en snap van het script niet echt veel. Ik hoop dat jullie de fout kunnen zien.
Warning: Bad Message destination in c:\apache\htdocs\test\test1.php on line 103
Ik gebruik het volgende script
PHP:
1
| <?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <title></title></head><body><form action=test1.php method=post ENCTYPE="multipart/form-data" ><table><tr><td>From (name):</td><td><input type=text name=from_name></td></tr><tr><td>From (Email):</td><td><input type=text name=from></td></tr><tr><td>To (name):</td><td><input type=text name=to_name></td></tr><tr><td>To (Email):</td><td><input type=text name=to></td></tr><tr><td>Subject:</td><td><input type=text name=subject></td></tr><tr><td>Message</td><td><textarea name=message>Test message</textarea></td></tr><tr><td>Message (html format)</td><td><textarea name=message_html>&lt;b&gt;Test&lt;/b&gt; message</textarea></td></tr><tr><td>Attach file1</td><td><input type=file name=file1></td></tr><tr><td>Attach file2</td><td><input type=file name=file2></td></tr><tr><td>Attach file3</td><td><input type=file name=file3></td></tr></table><input type=submit value=Send></form><?php class CMIMEMail { var $to; var $boundary; var $smtp_headers; var $filename_real; var $body_plain; var $body_html; var $atcmnt; var $atcmnt_type; function CMIMEMail($to,$from,$subject,$priority=3) { $this->to=$to; $this->from=$from; $this->subject=$subject; $this->priority=$priority; $this->boundary="----=_NextPart_".time()."_".md5(time())."_"; } function mailbody( $plain, $html="" ) { $this->body_plain=$plain; $this->body_html=$html; } function attach( $name, $content_type, $data ) { } function attachfile_raw( $fname, $mailFileName, $content_type ) { if($f=@fopen($fname,"r")) { $this->atcmnt[$mailFileName]=fread($f,filesize($fname)); $this->atcmnt_type[$mailFileName]=$content_type; fclose($f); } } function attachfile( $fname, $content_type ) { attachfile_raw($fname,$fname,$content_type); } function clear() { unset( $atcmnt ); unset( $atcmnt_type ); } function makeheader() { $out ="From: ".$this->from."\n"; $out.="Reply-To: ".$this->from."\n"; $out.="MIME-Version: 1.0\n". "Content-Type: multipart/mixed;\n\t boundary=\"".$this->boundary."\"\n". "X-Priority: ".$this->priority."\n". "X-Mailer: phpMimeMail ( http://www.ziet.zhitomir.ua/~rozhik/php3/mimemail/ )\n"; return $out; } function makebody() { $boundary2= "----=_NextAttachedPart_".time()."_".md5(time()+101)."_"; $out=""; if( " ".$this->body_html!=" " ) { $out="\nThis is a multi-part message in MIME format.\n\n"; $out.="--".$this->boundary."\nContent-Type: multipart/alternative;\n\tboundary=\"$boundary2\"\n"; $out.="$body_plan\n". "--$boundary2\nContent-Type: text/plain\n".# "Content-Disposition: inline\n". "Content-Transfer-Encoding: quoted-printable\n\n". $this->body_plain. "\n\n--$boundary2\n". "Content-Type: text/html\n".# "Content-Disposition: attachment;\n\tfilename=\"message.html\"\n". "Conent-Transfer-Encoding: quoted-printable\n". "\n$this->body_html\n\n". "--$boundary2--\n"; } else { $out="\n\n".$this->body_plain."\n\n"; $out.="--".$this->boundary."\n". "Content-Type: text/plain\n". "Content-Transfer-Encoding: quoted-printable\n\n". $this->body_plain. "\n\n--".$this->boundary. "\n"; } if( is_array( $this->atcmnt_type ) ) { reset( $this->atcmnt_type); while( list($name, $content_type) = each($this->atcmnt_type) ) { $out.="\n--".$this->boundary."\nContent-Type: $content_type\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename=\"$name\"\n\n". chunk_split(base64_encode($this->atcmnt[$name]))."\n"; } } $out.="\n--".$this->boundary."--\n"; return $out; } function send(){ mail("$this->to", "$this->subject", "$this->makebody()", "$this->makeheader()" ); } } $m = new CMIMEMail("$to_name <$to>","$from_name <$from>","$subject"); $m->mailbody($message,$message_html); if( $file1) {$m->attachFile_raw($file1,$file1_name,$file1_type);}; if( $file2) {$m->attachFile_raw($file2,$file2_name,$file2_type);}; if( $file3) {$m->attachFile_raw($file3,$file3_name,$file3_type);}; $m->send(); ?></body></html>?> |
-