php mail - from mail
Beste webmasters,
Ik heb een probleem bij het verzenden van een email via mijn website heeft de afzender mijn email.
Ik zou graag hebben dat ik dan de klant zijn email zie staan.
Hopelijk kunnen jullie me helpen alvast dank
Ik heb een probleem bij het verzenden van een email via mijn website heeft de afzender mijn email.
Ik zou graag hebben dat ik dan de klant zijn email zie staan.
Hopelijk kunnen jullie me helpen alvast dank
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
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
<?php
/* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input function */
$yourname = check_input($_POST['yourname'], "Enter your name");
$subject = check_input($_POST['subject'], "Write a subject");
$email = check_input($_POST['email']);
$telefoon = check_input($_POST['telefoon']);
$likeit = check_input($_POST['likeit']);
$how_find = check_input($_POST['how']);
$comments = check_input($_POST['comments'], "Write your comments");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
E-mail: $email
Telefoon: $telefoon
Like the website? $likeit
How did he/she find it? $how_find
Comments:
$comments
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message ,"-f [email protected]");
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
/* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input function */
$yourname = check_input($_POST['yourname'], "Enter your name");
$subject = check_input($_POST['subject'], "Write a subject");
$email = check_input($_POST['email']);
$telefoon = check_input($_POST['telefoon']);
$likeit = check_input($_POST['likeit']);
$how_find = check_input($_POST['how']);
$comments = check_input($_POST['comments'], "Write your comments");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
E-mail: $email
Telefoon: $telefoon
Like the website? $likeit
How did he/she find it? $how_find
Comments:
$comments
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message ,"-f [email protected]");
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
In de From komt nooit het e-mailadres van de bezoeker.
http://phpwiki.santhe.nl/index.php?title=De_juiste_mailheaders
http://phpwiki.santhe.nl/index.php?title=De_juiste_mailheaders
- SanThe - op 18/03/2016 11:25:20:
In de From komt nooit het e-mailadres van de bezoeker.
http://phpwiki.santhe.nl/index.php?title=De_juiste_mailheaders
http://phpwiki.santhe.nl/index.php?title=De_juiste_mailheaders
Ik ben wel benieuwd naar de reden? Want het klinkt wel logisch.
Vallen spamfilters er soms over? Voor de afzender is Reply-To wel de juiste.
Maar waarom juist niet From?
De werkelijke verzender is de (mail)server (met eventueel jou als afzender).
Dat is waar het spf-record naar kijkt.
Dat is waar het spf-record naar kijkt.
Wat zie je dan als je het ontvangt? Je ziet niet in het bericht zelf het e-mail adres? Of niet in de from? Want als het niet in de from is dan is het wat sann zegt. Met phpmailer kan je bijvoorbeeld die wel instellen, maar op dit moment (gezien de code die je geeft) geef je geen from aan dus krijg je die ook niet.
Gewijzigd op 19/03/2016 17:36:55 door L deB




