problemen met php mailer
Ik ben Freddy en onderhoud de website van een countrygroep.
Momenteel hebben we te maken met spam op het contact formulier
Ik zou graag een php contact formulier plaatsen maar bij het resten op een test webhosting krijg ik wel geen respons.
dit is het adres van de test site:http://countryboyfred.epizy.com/contact.html.
Ik zal nog hetcontact formulier en contactphp meesturen
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Delphic | Creative Portfolio Template</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<link rel="stylesheet" type="text/css" href="contact/style.css" media="all" />
<script type="text/javascript">
$(function(){ $("label").inFieldLabels(); });
</script>
<script type="text/javascript">
getTwitters('twitter', {
id: 'elemisdesign',
count: 1,
enableLinks: true,
ignoreReplies: false,
template: '<span class="twitterPrefix"><span class="twitterStatus">%text%</span>',
newwindow: true
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#ajax-contact-form").submit(function() {
$('#load').append('<center><img src="ajax-loader.gif" alt="Currently Loading" id="loading" /></center>');
var fem = $(this).serialize(),
note = $('#note');
$.ajax({
type: "POST",
url: "contact/contact.php",
data: fem,
success: function(msg) {
if ( note.height() ) {
note.slideUp(500, function() { $(this).hide(); });
}
else note.hide();
$('#loading').fadeOut(300, function() {
$(this).remove();
// Message Sent? Show the 'Thank You' message and hide the form
result = (msg === 'OK') ? '<div class="success">Your message has been sent. Thank you!</div>' : msg;
var i = setInterval(function() {
if ( !note.is(':visible') ) {
note.html(result).slideDown(500);
clearInterval(i);
}
}, 40);
}); // end loading image fadeOut
}
});
return false;
});
});
</script>
</head>
<body>
<div id="container">
<!-- Begin Header Wrapper -->
<div id="page-top">
<div id="header-wrapper">
<!-- Begin Header -->
<div id="header">
<div id="logo"><a href="index.html"><img src="style/images/logo.png" alt="Delphic" /></a></div>
<!-- Logo -->
<!-- Begin Menu -->
<div id="menu-wrapper">
<div id="smoothmenu1" class="ddsmoothmenu">
<ul>
<li><a href="index.html">home</a>
<li><a href="video-fotos.html">video-foto</a>
<li><a href="playlist.html">playlist</a>
<li><a href="agenda.html">gigs</a>
<li><a href="links.html">links</a>
<li><a href="contact.html">contact</a>
</ul>
</div>
</div>
<!-- End Menu -->
</div>
<!-- End Header -->
</div>
</div>
<!-- End Header Wrapper -->
<!-- Begin Wrapper -->
<div id="wrapper">
<!-- Begin Content -->
<div class="content">
<div style=" text-align: center "><h1>CONTACT</h1> </div>
<br />
<br />
<br />
<br />
<h3>GSM: 0495/232478 </h3>
<h3>EMAIL: [email protected]</h3>
<h3>Heeft u nog een vraag?</h3>
<h3>Aarzel dan niet contact op te nemen via onderstaand formulier</h3>
<br />
<br />
<br />
<br />
<!-- Begin Form -->
<div class="contact-left">
<div id="contact-form">
<!--begin:notice message block-->
<div id="note"></div>
<!--begin:notice message block-->
<form id="ajax-contact-form" method="post" action="javascript:alert('success!');">
<div class="labels">
<p>
<label for="name">Name</label>
<br />
<input class="required inpt" type="text" name="name" id="name" value="" />
</p>
<p>
<label for="email">E-Mail</label>
<br />
<input class="required inpt" type="text" name="email" id="email" value="" />
</p>
</div>
<div class="comments">
<p>
<textarea class="textbox" name="message" rows="6" cols="30"></textarea>
</p>
<br />
<p>
<label for="answer">5+1=?</label>
<br />
<input class="required inpt" type="text" name="answer" id="answer" value="" />
</p>
</div>
<label id="load" style="display:none"></label>
<input id="submit-button" class="button gray stripe" type="submit" name="submit" value="Send Message" />
</form>
</div>
<!-- End Form -->
</div>
<div class="contact-right">
<div class="one-half">
<div class="clear"></div>
<br />
<iframe width="400" height="188" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?hl=en&ie=UTF8&msa=0&msid=207283647702034942388.00049e0aeaa1c22ac0897&ll=41.035082,29.001846&spn=0.044025,0.143852&z=12&output=embed"></iframe>
</div>
<div class="clear"></div>
<div class="divider"></div>
<div id="twitter-wrapper">
<div id="twitter"></div>
<span class="username">Follow <a href="http://twitter.com/elemisdesign">elemisdesign</a></span> </div>
<div class="clear"></div>
</div>
<!-- End Content -->
</div>
<!-- End Wrapper -->
<div class="clearfix"></div>
<div class="push"></div>
</div>
<!-- Begin Footer -->
<div id="footer-wrapper">
<div id="footer">
<div id="footer-content">
<!-- Begin Copyright -->
<div id="copyright">
<p> Copyright 2011 Delphic | Creative Portfolio Template</p>
</div>
<!-- End Copyright -->
<!-- Begin Social Icons -->
<div id="socials">
<ul>
</ul>
</div>
<!-- End Social Icons -->
</div>
</div>
</div>
<!-- End Footer -->
</body>
</html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Delphic | Creative Portfolio Template</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<link rel="stylesheet" type="text/css" href="contact/style.css" media="all" />
<script type="text/javascript">
$(function(){ $("label").inFieldLabels(); });
</script>
<script type="text/javascript">
getTwitters('twitter', {
id: 'elemisdesign',
count: 1,
enableLinks: true,
ignoreReplies: false,
template: '<span class="twitterPrefix"><span class="twitterStatus">%text%</span>',
newwindow: true
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#ajax-contact-form").submit(function() {
$('#load').append('<center><img src="ajax-loader.gif" alt="Currently Loading" id="loading" /></center>');
var fem = $(this).serialize(),
note = $('#note');
$.ajax({
type: "POST",
url: "contact/contact.php",
data: fem,
success: function(msg) {
if ( note.height() ) {
note.slideUp(500, function() { $(this).hide(); });
}
else note.hide();
$('#loading').fadeOut(300, function() {
$(this).remove();
// Message Sent? Show the 'Thank You' message and hide the form
result = (msg === 'OK') ? '<div class="success">Your message has been sent. Thank you!</div>' : msg;
var i = setInterval(function() {
if ( !note.is(':visible') ) {
note.html(result).slideDown(500);
clearInterval(i);
}
}, 40);
}); // end loading image fadeOut
}
});
return false;
});
});
</script>
</head>
<body>
<div id="container">
<!-- Begin Header Wrapper -->
<div id="page-top">
<div id="header-wrapper">
<!-- Begin Header -->
<div id="header">
<div id="logo"><a href="index.html"><img src="style/images/logo.png" alt="Delphic" /></a></div>
<!-- Logo -->
<!-- Begin Menu -->
<div id="menu-wrapper">
<div id="smoothmenu1" class="ddsmoothmenu">
<ul>
<li><a href="index.html">home</a>
<li><a href="video-fotos.html">video-foto</a>
<li><a href="playlist.html">playlist</a>
<li><a href="agenda.html">gigs</a>
<li><a href="links.html">links</a>
<li><a href="contact.html">contact</a>
</ul>
</div>
</div>
<!-- End Menu -->
</div>
<!-- End Header -->
</div>
</div>
<!-- End Header Wrapper -->
<!-- Begin Wrapper -->
<div id="wrapper">
<!-- Begin Content -->
<div class="content">
<div style=" text-align: center "><h1>CONTACT</h1> </div>
<br />
<br />
<br />
<br />
<h3>GSM: 0495/232478 </h3>
<h3>EMAIL: [email protected]</h3>
<h3>Heeft u nog een vraag?</h3>
<h3>Aarzel dan niet contact op te nemen via onderstaand formulier</h3>
<br />
<br />
<br />
<br />
<!-- Begin Form -->
<div class="contact-left">
<div id="contact-form">
<!--begin:notice message block-->
<div id="note"></div>
<!--begin:notice message block-->
<form id="ajax-contact-form" method="post" action="javascript:alert('success!');">
<div class="labels">
<p>
<label for="name">Name</label>
<br />
<input class="required inpt" type="text" name="name" id="name" value="" />
</p>
<p>
<label for="email">E-Mail</label>
<br />
<input class="required inpt" type="text" name="email" id="email" value="" />
</p>
</div>
<div class="comments">
<p>
<textarea class="textbox" name="message" rows="6" cols="30"></textarea>
</p>
<br />
<p>
<label for="answer">5+1=?</label>
<br />
<input class="required inpt" type="text" name="answer" id="answer" value="" />
</p>
</div>
<label id="load" style="display:none"></label>
<input id="submit-button" class="button gray stripe" type="submit" name="submit" value="Send Message" />
</form>
</div>
<!-- End Form -->
</div>
<div class="contact-right">
<div class="one-half">
<div class="clear"></div>
<br />
<iframe width="400" height="188" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?hl=en&ie=UTF8&msa=0&msid=207283647702034942388.00049e0aeaa1c22ac0897&ll=41.035082,29.001846&spn=0.044025,0.143852&z=12&output=embed"></iframe>
</div>
<div class="clear"></div>
<div class="divider"></div>
<div id="twitter-wrapper">
<div id="twitter"></div>
<span class="username">Follow <a href="http://twitter.com/elemisdesign">elemisdesign</a></span> </div>
<div class="clear"></div>
</div>
<!-- End Content -->
</div>
<!-- End Wrapper -->
<div class="clearfix"></div>
<div class="push"></div>
</div>
<!-- Begin Footer -->
<div id="footer-wrapper">
<div id="footer">
<div id="footer-content">
<!-- Begin Copyright -->
<div id="copyright">
<p> Copyright 2011 Delphic | Creative Portfolio Template</p>
</div>
<!-- End Copyright -->
<!-- Begin Social Icons -->
<div id="socials">
<ul>
</ul>
</div>
<!-- End Social Icons -->
</div>
</div>
</div>
<!-- End Footer -->
</body>
</html>
en contact.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
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
<?php
// Do not edit this if you are not familiar with php
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
$replyto='[email protected]';
$subject = 'Contact Form Results';
if($post)
{
function ValidateEmail($email)
{
$regex = "/([a-z0-9_\.\-]+)". # name
"@". # at
"([a-z0-9\.\-]+){2,255}". # domain & possibly subdomains
"\.". # period
"([a-z]+){2,10}/i"; # domain extension
$eregi = preg_replace($regex, '', $email);
return empty($eregi) ? true : false;
}
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$message = stripslashes($_POST['message']);
$phone = stripslashes($_POST['phone']);
$answer = trim($_POST['answer']);
$verificationanswer="6"; // plz change edit your human answer
$from=$email;
$to=$replyto;
$error = '';
$headers= "From: $name <" . $email . "> \n";
$headers.= "Reply-to:" . $email . "\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers = "Content-Type: text/html; charset=utf-8\n".$headers;
// Checks Name Field
if(!$name || !$email || $email && !ValidateEmail($email) || $answer <> $verificationanswer || !$message || strlen($message) < 1)
{
$error .= 'Please fill the required fields correctly.<br />';
}
if(!$error)
{
$messages.="Name: $name <br>";
$messages.="Email: $email <br>";
$messages.="Message: $message <br>";
$mail = mail($to,$subject,$messages,$headers);
if($mail)
{
echo 'OK';
if($autorespond == "yes")
{
include("autoresponde.php");
}
}
}
else
{
echo '<div class="error">'.$error.'</div>';
}
}
?>
// Do not edit this if you are not familiar with php
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
$replyto='[email protected]';
$subject = 'Contact Form Results';
if($post)
{
function ValidateEmail($email)
{
$regex = "/([a-z0-9_\.\-]+)". # name
"@". # at
"([a-z0-9\.\-]+){2,255}". # domain & possibly subdomains
"\.". # period
"([a-z]+){2,10}/i"; # domain extension
$eregi = preg_replace($regex, '', $email);
return empty($eregi) ? true : false;
}
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$message = stripslashes($_POST['message']);
$phone = stripslashes($_POST['phone']);
$answer = trim($_POST['answer']);
$verificationanswer="6"; // plz change edit your human answer
$from=$email;
$to=$replyto;
$error = '';
$headers= "From: $name <" . $email . "> \n";
$headers.= "Reply-to:" . $email . "\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers = "Content-Type: text/html; charset=utf-8\n".$headers;
// Checks Name Field
if(!$name || !$email || $email && !ValidateEmail($email) || $answer <> $verificationanswer || !$message || strlen($message) < 1)
{
$error .= 'Please fill the required fields correctly.<br />';
}
if(!$error)
{
$messages.="Name: $name <br>";
$messages.="Email: $email <br>";
$messages.="Message: $message <br>";
$mail = mail($to,$subject,$messages,$headers);
if($mail)
{
echo 'OK';
if($autorespond == "yes")
{
include("autoresponde.php");
}
}
}
else
{
echo '<div class="error">'.$error.'</div>';
}
}
?>
contact.php staat in een map contact en onder contact.html.
De velden moeten allemaal ingevuld zijn en als ik dan op versturen druk blijft de button ingedrukt en er gebeurt niets.
Edit:
Ik heb code-tags geplaatst. Gelieve dit in het vervolg zelf toe te voegen aan je bericht.
Zie ook: Veel gestelde vragen: Welke UBB-codes kan ik gebruiken.
Zie ook: Veel gestelde vragen: Welke UBB-codes kan ik gebruiken.
Gewijzigd op 12/03/2019 21:22:52 door - Ariën -
Ik zie gewoon een bericht dat de mail verzonden is?
Dat is het juist de form zegt mail verzonden maar er komt geenmail toe.
Al twee maal email adres gewijzigd in mail.php maat niets.
Waar kan het fout lopen?
* Headers zijn niet goed. Gebruik deze eens deze: http://wiki.phpbeginners.nl/index.php?title=De_juiste_mailheaders
* Mailen is niet mogelijk op de server
* Server staat op een blacklist wegens spam
* Mails worden in de spambox geplaatst, kijk daar eens.
* Mails worden geweigerd omdat er geen SPF of DKIM regel in de DNS staat. Vaak bij geadresseerden zoals Hotmail/Outlook en Gmail.
Zelf gebruik ik liever phpMailer om direct met de SMTP-server te 'praten'. Zie ook dit voorbeeld: https://github.com/PHPMailer/PHPMailer/blob/master/examples/smtp.phps
In dit geval kan je dit makkelijker 'debuggen'.
Gewijzigd op 13/03/2019 13:09:58 door - Ariën -