mail script doet raar???
Ik ben hier niet thuis in en ben een groentje hier op dit form en in php.
Maar ik heb een probleem.
Mijn mail script doet raar. als ik deze invul die op de server staat die php ondersteund krijg ik codes terug i.p.v. een mooi rijtje letters onder elkaar.
Zie hier:
X-Priority: 3
X-MSMail-Priority: High
X-Mailer: My PHP Mailer
Content-Type: multipart/mixed;
boundary="----=_OuterBoundary_000"
This is a multi-part message in MIME format.
------=_OuterBoundary_000
Content-Type: multipart/alternative;
boundary="----=_InnerBoundery_001"
------=_InnerBoundery_001
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Untitled Document
Naam:jeroen
Adres:straat
Postcode:0000
Plaats:0000
E-mail:
Stel uw vraag dit is een test
------=_InnerBoundery_001
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: base64
PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25h
bC5kdGQiPgo8aHRtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+CjxoZWFk
Pgo8bWV0YSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNvbnRlbnQ9InRleHQvaHRtbDsgY2hh
cnNldD1pc28tODg1OS0xIiAvPgo8dGl0bGU+VW50aXRsZWQgRG9jdW1lbnQ8L3RpdGxlPgo8L2hl
YWQ+Cgo8Ym9keT4KCiAgPHRhYmxlPgogICAgPHRyPjx0ZD5OYWFtOjwvdGQ+PHRkPmplcm9lbjwv
dGQ+PC90cj4KICAgIDx0cj48dGQ+QWRyZXM6PC90ZD48dGQ+c3RyYWF0PC90ZD48L3RyPgogICAg
PHRyPjx0ZD5Qb3N0Y29kZTo8L3RkPjx0ZD4wMDAwPC90ZD48L3RyPgogICAgPHRyPjx0ZD5QbGFh
dHM6PC90ZD48dGQ+MDAwMDwvdGQ+PC90cj4KICAgIDx0cj48dGQ+RS1tYWlsOjwvdGQ+PHRkPmpl
cm9lbnZhbmRlcnBAZ21haWwuY29tPC90ZD48L3RyPgogICAgPHRyPjx0ZD5TdGVsIHV3IHZyYWFn
PC90ZD48dGQ+ZGl0IGlzIGVlbiB0ZXN0PC90ZD48L3RyPgogIDwvdGFibGU+Cgo8L2JvZHk+Cjwv
aHRtbD4K
------=_InnerBoundery_001--
------=_OuterBoundary_000--
Jeroen ploeg op 24/02/2011 23:37:08:
Beste php-ers,
Ik ben hier niet thuis in en ben een groentje hier op dit form en in php.
Maar ik heb een probleem.
Mijn mail script doet raar. als ik deze
Ik ben hier niet thuis in en ben een groentje hier op dit form en in php.
Maar ik heb een probleem.
Mijn mail script doet raar. als ik deze
Welke is 'deze'?
Quote:
invul die op de server staat die php ondersteund krijg ik codes terug
Wat voor codes...
Quote:
i.p.v. een mooi rijtje letters onder elkaar.
Huh, leg uit?
Want wat je daar ziet is het mailtje, maar dan zonder dat een mailprogramma het gedecodeerd heeft.
Welke code voer je uit, waardoor je dit resultaat krijgt?
Dat lijkt me cruciaal om uberhaupt een verklaring te kunnen geven voor je probleem.
chups.
Het lijkt er ook op dat je een bijlage mee wilt sturen. Laat eens een (klein) stukje code zien wat naar jou mening niet goed werkt. Betreft het een nieuw script of een bestaand script dat je hebt aangepast en nu niet meer werkt?
Hieronder wat codes.
mail.php
Code (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
69
70
71
72
73
74
75
76
77
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
69
70
71
72
73
74
75
76
77
<?php
function SendMail($From,$FromName,$To,$ToName,$ToCC,$ToNameCC,$ToBCC,$ToNameBCC,$Subject,$Text,$Html,$AttmFiles){
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text)
or die("neither text nor html part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
$headers ="MIME-Version: 1.0\r\n";
$headers.="From: ".$FromName." <".$From.">\r\n";
$headers.="To: ".$ToName." <".$To.">\r\n";
if ($ToNameCC != ""){
$headers.="CC: ".$ToNameCC." <".$ToCC.">\r\n";
}
if ($ToNameBCC != ""){
$headers.="BCC: ".$ToNameBCC." <".$ToBCC.">\r\n";
}
$headers.="Reply-To: ".$FromName." <".$From.">\r\n";
$headers.="X-Priority: 3\r\n";
$headers.="X-MSMail-Priority: High\r\n";
$headers.="X-Mailer: My PHP Mailer\r\n";
$headers.="Content-Type: multipart/mixed;\n\tboundary=\"".$OB."\"\r\n";
//Messages start with text/html alternatives in OB
$Msg ="This is a multi-part message in MIME format.\r\n";
$Msg.="\n--".$OB."\r\n";
$Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\r\n\r\n";
//plaintext section
$Msg.="\n--".$IB."\r\n";
$Msg.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\r\n";
$Msg.="Content-Transfer-Encoding: quoted-printable\r\n\r\n";
// plaintext goes here
$Msg.=$Text."\r\n\r\n";
// html section
$Msg.="\r\n--".$IB."\r\n";
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\r\n";
$Msg.="Content-Transfer-Encoding: base64\r\n\r\n";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."\r\n\r\n";
// end of IB
$Msg.="\r\n--".$IB."--\r\n";
// attachments
/*
foreach($AttmFiles as $AttmFile){
if(!empty($AttmFile)){
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
$Msg.= "\n--".$OB."\n";
$Msg.="Content-Type: application/octetstream;\n\tname=\"".$FileName."\"\n";
$Msg.="Content-Transfer-Encoding: base64\n";
$Msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\n\n";
if (file_exists($AttmFile)){
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="\n\n";
}
}
}
*/
//message ends
$Msg.="\r\n--".$OB."--\r\n";
mail($To,$Subject,$Msg,$headers);
}
?>
function SendMail($From,$FromName,$To,$ToName,$ToCC,$ToNameCC,$ToBCC,$ToNameBCC,$Subject,$Text,$Html,$AttmFiles){
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text)
or die("neither text nor html part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
$headers ="MIME-Version: 1.0\r\n";
$headers.="From: ".$FromName." <".$From.">\r\n";
$headers.="To: ".$ToName." <".$To.">\r\n";
if ($ToNameCC != ""){
$headers.="CC: ".$ToNameCC." <".$ToCC.">\r\n";
}
if ($ToNameBCC != ""){
$headers.="BCC: ".$ToNameBCC." <".$ToBCC.">\r\n";
}
$headers.="Reply-To: ".$FromName." <".$From.">\r\n";
$headers.="X-Priority: 3\r\n";
$headers.="X-MSMail-Priority: High\r\n";
$headers.="X-Mailer: My PHP Mailer\r\n";
$headers.="Content-Type: multipart/mixed;\n\tboundary=\"".$OB."\"\r\n";
//Messages start with text/html alternatives in OB
$Msg ="This is a multi-part message in MIME format.\r\n";
$Msg.="\n--".$OB."\r\n";
$Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\r\n\r\n";
//plaintext section
$Msg.="\n--".$IB."\r\n";
$Msg.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\r\n";
$Msg.="Content-Transfer-Encoding: quoted-printable\r\n\r\n";
// plaintext goes here
$Msg.=$Text."\r\n\r\n";
// html section
$Msg.="\r\n--".$IB."\r\n";
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\r\n";
$Msg.="Content-Transfer-Encoding: base64\r\n\r\n";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."\r\n\r\n";
// end of IB
$Msg.="\r\n--".$IB."--\r\n";
// attachments
/*
foreach($AttmFiles as $AttmFile){
if(!empty($AttmFile)){
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
$Msg.= "\n--".$OB."\n";
$Msg.="Content-Type: application/octetstream;\n\tname=\"".$FileName."\"\n";
$Msg.="Content-Transfer-Encoding: base64\n";
$Msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\n\n";
if (file_exists($AttmFile)){
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="\n\n";
}
}
}
*/
//message ends
$Msg.="\r\n--".$OB."--\r\n";
mail($To,$Subject,$Msg,$headers);
}
?>
index.php
Code (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
class sendTheMail {
var $postVars;
var $redirect;
var $tmplPath;
var $createdMail;
var $createdTxt;
var $email;
var $bccemail;
var $conf;
var $name;
var $From;
var $FromName;
var $ToCC;
var $ToNameCC;
var $ToBCC;
var $ToNameBCC;
var $Subject;
var $AttmFiles;
function sendTheMail($postedVars){
$this->postVars = $postedVars;
$this->redirect = $postedVars['redirect'];
$this->email = $postedVars['email'];
$this->name = $postedVars['name'];
$this->bccemail = $postedVars['bccemail'];
$this->conf = $postedVars['conf'] . ".php";
require_once("mail.php");
require_once($this->conf);
$this->tmplPath = $tmpl;
$this->redirect = $redirect;
$this->From = $From;
$this->FromName = $FromName;
$this->ToCC = $ToCC;
$this->ToNameCC = $ToNameCC;
$this->ToBCC = $ToBCC;
$this->ToNameBCC = $ToNameBCC;
$this->Subject = $Subject;
$this->AttmFiles = 0;
$this->createTheMail();
}
function createTheMail(){
if (!$tmpl = fopen($this->tmplPath,"r")){
$error = 1;
} else {
$mailContent = fread($tmpl,filesize($this->tmplPath));
fclose($tmpl);
for ($i = 0; $i < sizeof($this->postVars); $i++){
$tempKey = "<##" . key($this->postVars) . "##>";
$mailContent = eregi_replace($tempKey, $this->postVars[key($this->postVars)], $mailContent);
next($this->postVars);
}
$mailContent = preg_replace('/<##([^>]*)##>/i','',$mailContent);
$mailContent;
$this->createdMail = $mailContent;
$createdTxt = eregi_replace("<br />", "\n", $mailContent);
$createdTxt = eregi_replace("<br/>", "\n", $createdTxt);
$createdTxt = eregi_replace("<br>", "\n", $createdTxt);
$createdTxt = eregi_replace("<BR />", "\n", $createdTxt);
$createdTxt = eregi_replace("<BR/>", "\n", $createdTxt);
$createdTxt = eregi_replace("<BR>", "\n", $createdTxt);
$this->createdTxt = strip_tags($createdTxt);
}
}
function sendOutMail(){
SendMail($this->From,$this->FromName,$this->email,$this->name,$this->ToCC,$this->ToNameCC,$this->ToBCC,$this->ToNameBCC,$this->Subject,$this->createdTxt,$this->createdMail,$this->AttmFiles);
// return $this->createdMail;
$this->makeRedirect();
}
function makeRedirect(){
header("Location:".$this->redirect);
}
}
$showVars = new sendTheMail($_POST);
print $showVars->sendOutMail();
?>
class sendTheMail {
var $postVars;
var $redirect;
var $tmplPath;
var $createdMail;
var $createdTxt;
var $email;
var $bccemail;
var $conf;
var $name;
var $From;
var $FromName;
var $ToCC;
var $ToNameCC;
var $ToBCC;
var $ToNameBCC;
var $Subject;
var $AttmFiles;
function sendTheMail($postedVars){
$this->postVars = $postedVars;
$this->redirect = $postedVars['redirect'];
$this->email = $postedVars['email'];
$this->name = $postedVars['name'];
$this->bccemail = $postedVars['bccemail'];
$this->conf = $postedVars['conf'] . ".php";
require_once("mail.php");
require_once($this->conf);
$this->tmplPath = $tmpl;
$this->redirect = $redirect;
$this->From = $From;
$this->FromName = $FromName;
$this->ToCC = $ToCC;
$this->ToNameCC = $ToNameCC;
$this->ToBCC = $ToBCC;
$this->ToNameBCC = $ToNameBCC;
$this->Subject = $Subject;
$this->AttmFiles = 0;
$this->createTheMail();
}
function createTheMail(){
if (!$tmpl = fopen($this->tmplPath,"r")){
$error = 1;
} else {
$mailContent = fread($tmpl,filesize($this->tmplPath));
fclose($tmpl);
for ($i = 0; $i < sizeof($this->postVars); $i++){
$tempKey = "<##" . key($this->postVars) . "##>";
$mailContent = eregi_replace($tempKey, $this->postVars[key($this->postVars)], $mailContent);
next($this->postVars);
}
$mailContent = preg_replace('/<##([^>]*)##>/i','',$mailContent);
$mailContent;
$this->createdMail = $mailContent;
$createdTxt = eregi_replace("<br />", "\n", $mailContent);
$createdTxt = eregi_replace("<br/>", "\n", $createdTxt);
$createdTxt = eregi_replace("<br>", "\n", $createdTxt);
$createdTxt = eregi_replace("<BR />", "\n", $createdTxt);
$createdTxt = eregi_replace("<BR/>", "\n", $createdTxt);
$createdTxt = eregi_replace("<BR>", "\n", $createdTxt);
$this->createdTxt = strip_tags($createdTxt);
}
}
function sendOutMail(){
SendMail($this->From,$this->FromName,$this->email,$this->name,$this->ToCC,$this->ToNameCC,$this->ToBCC,$this->ToNameBCC,$this->Subject,$this->createdTxt,$this->createdMail,$this->AttmFiles);
// return $this->createdMail;
$this->makeRedirect();
}
function makeRedirect(){
header("Location:".$this->redirect);
}
}
$showVars = new sendTheMail($_POST);
print $showVars->sendOutMail();
?>
config.php
Code (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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
// Dit is de afzender en het replay adres
$From = "info@___________.nl";
$FromName = "een titel";
// cc
$ToCC = "";
$ToNameCC = "";
// bcc
$ToBCC = "info@n________.nl";
$ToNameBCC = "een titel";
// onderwerp
$Subject = "Reactie van de site";
// Dit is het pad naar de pagina waar men komt na het versturen van de mail.
// Dit kan een relative of een absolute url zijn.
$redirect = "../bedankt.htm";
// Dit is het pad naar een template voor de email.
// Dit moet een relative url zijn. Of wel met puntjes "../dir/file"
$tmpl = "../tmpl/mailLayout.html";
?>
// Dit is de afzender en het replay adres
$From = "info@___________.nl";
$FromName = "een titel";
// cc
$ToCC = "";
$ToNameCC = "";
// bcc
$ToBCC = "info@n________.nl";
$ToNameBCC = "een titel";
// onderwerp
$Subject = "Reactie van de site";
// Dit is het pad naar de pagina waar men komt na het versturen van de mail.
// Dit kan een relative of een absolute url zijn.
$redirect = "../bedankt.htm";
// Dit is het pad naar een template voor de email.
// Dit moet een relative url zijn. Of wel met puntjes "../dir/file"
$tmpl = "../tmpl/mailLayout.html";
?>
IK hoop dat jullie de fout eruit kunnen helen????
Met vriendelijke groet,
Jeroen