Ik gebruik de onderstaande functie om een mailtje met attachement te versturen. Alles gaat goed, alleen af en toe wordt de mail 1 of dan 2 of dan 3 of dan 4 keer verzonden.
Waar kan dit aan liggen? Heb al eens gezocht maar ik vind niets in de functie.
Ik heb wel al op aanraden van het script zelf de \r verwijderd, zonder resultaat!
Waar kan dit aan liggen? Heb al eens gezocht maar ik vind niets in de functie.
Ik heb wel al op aanraden van het script zelf de \r verwijderd, zonder resultaat!
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| // MAILSCRIPT //////////////////////////////////////////////// // Your mail messsage //$msg = "$msgcontent"; // who the message is to $mailto = "ik@moblog.nl"; // who the message is from $mailfrom = "afzender@afzender.nl"; // what is the mail subject $mailsubj = "$md->subject"; // file name to attach //$fattach = "part_1.jpg"; // path to file location on server // no trailing [ / ] $fl = $dir_name; /// script $a_name = "phpmail"; $timer = time(); $abound = "00-".$a_name."-".$timer.""; $stime = date("r",time()); $mhead = "Date: ".$stime."\r\n"; $mhead .= "From: ".$mailfrom."\r\n"; $mhead .= "To: ".$mailto."\r\n"; $mhead .= "X-Priority: 3 (Normal)\r\n"; $mhead .= "X-Mailer: <PHP MAILER>\r\n"; $mhead .= "MIME-Version: 1.0\r\n"; $mhead .= "Content-Type: multipart/mixed; boundary=\"$abound\"\r\n"; $mhead .= "Content-Transfer-Encoding: 8bit\r\n"; // some smtp servers (routers) don't like (\r) in the mailbody string so remove them // It will not effect servers that do allow them $msg = preg_replace("/\n/i", "\n", $msg); $msgbody = "--".$abound.""; $msgbody .= "\n"; $msgbody .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\n"; $msgbody .= "Content-Transfer-Encoding: 8bit;\n\n"; $msgbody .= "$msgcontent "; $msgbody .= "\n"; $msgbody .= "\n"; $msgbody .= "\n"; $ahead = "--".$abound.""; $ahead .= "\n"; $ahead .= "Content-Type: application/octet-stream"; $ahead .= "\n"; $ahead .= "Content-Transfer-Encoding: base64"; $ahead .= "\n"; $ahead .= "Content-Disposition: attachment; filename=\"$fattach\""; $ahead .= "\n\n"; set_magic_quotes_runtime(0); $filehandle2 = fopen("$dir_name/$fattach", "rb"); $attachment = fread($filehandle2, filesize ("$dir_name/$fattach")); fclose ($filehandle2); $attachment = chunk_split(base64_encode($attachment)); // some smtp servers (routers) don't like (\r) in base64 strings so remove them // It will not effect servers that do allow them $attachment = preg_replace("/\n/i", "\n", $attachment); $ahead .= "$attachment"; $ahead .= "\n"; $msgbody .= "$ahead"; set_magic_quotes_runtime(get_magic_quotes_gpc()); $msgbody .= "--".$abound."--"; mail($mailto, $mailsubj, $msgbody, $mhead); //////////////////////////////////////////////////////////// |