Message could not be sent. Mailer Error:

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Marco Moens

Marco Moens

07/03/2014 21:34:05
Quote Anchor link
Ik heb een formulier gemaakt en krijg na verzenden Message could not be sent.Mailer Error:
De email komt gewoon aan. ik heb alles doorgelopen maar kan niets vinden (van wat ik er nu van weet "beginner')Hoop dat er iemand mij een tip kan geven, alvast bedankt voor de moeite.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php

require 'PHPMailerAutoload.php';

function
sendemail($contactpersoon, $adres, $postcode, $plaats, $telefoon, $email, $naamhond, $ras, $geslacht, $geboortedatum, $chipnummer, $Inentingen, $cursus, $opmerking, $akkoord, $lid)
{

    $mail = new PHPMailer();
    
    $mail->From = '[email protected]';
    $mail->addAddress('[email protected]', 'beheerder');  // Add a recipient
    $mail->AddReplyTo($email, $contactpersoon);
    $mail->addBCC('[email protected]');
    $mail->WordWrap = 60; // set word wrap
    
    $mail->Subject = "Aanmelding van $contactpersoon met $naamhond";
    $mail->Body .= "---------------Gegevens van de Eigenaar---------------\r\n\r\n";
    $mail->Body .= "Contactpersoon                    : $contactpersoon\r\n";
    $mail->Body .= "Adres                            : $adres\r\n";
    $mail->Body .= "Postcode                        : $postcode\r\n";
    $mail->Body .= "Plaats                            : $plaats\r\n";
    $mail->Body .= "Telefoon                        : $telefoon\r\n";
    $mail->Body .= "Email                            : $email\r\n\r\n";
    $mail->Body .= "---------------Gegevens van de Hond---------------\r\n\r\n";
    $mail->Body .= "Naam Hond                        : $naamhond\r\n";
    $mail->Body .= "Ras                            : $ras\r\n";
    $mail->Body .= "Geslacht                        : $geslacht\r\n";
    $mail->Body .= "Geboortedatum                    : $geboortedatum\r\n";
    $mail->Body .= "Chipnummer                        : $chipnummer\r\n";
    foreach($_POST['Inentingen'] as $Inentingen){
    $mail->Body .= "Inentingen                        : $Inentingen\n";}
    foreach($_POST['cursus'] as $cursus){
    $mail->Body .= "Opgeven voor cursus                    : $cursus\n";}
    $mail->Body .= "Opmerking                        : $opmerking\r\n";
    $mail->Body .= "Gaat akkoord met voorwaarden            : $akkoord\r\n";
    $mail->Body .= "Wil lid worden                        : $lid\r\n";

    $userip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$mail->Body .= "\n\nGebruikers IP: ". $userip;
    $mail->Body .= ". Dit formulier is ingevuld op: ";
    $tijd = time();  
$mail->Body .= $datum = strftime('%d/%m/%y %H:%M', $tijd);
                    
    if(!$mail->send()) {
        return true;
    }
    
    else
    {
       echo "Message could not be sent.";
       echo "Mailer Error: " . $mail->ErrorInfo;
       return false;
    }
}

function
validate($contactpersoon, $adres, $postcode, $plaats, $telefoon, $email, $naamhond, $ras, $geslacht, $geboortedatum, $chipnummer, $Inentingen, $cursus, $opmerking, $akkoord, $lid)
{

    $error = '';
    
    if($contactpersoon == '')
    $error ='naam invullen';
    
    if($adres == '')
    $error ='adres invullen';
    
    if($postcode == '')
    $error ='postcode invullen';
    
    if($plaats == '')
    $error ='plaats invullen';
    
    if($telefoon == '')
    $error ='telefoon invullen';
    
    if(!filter_var($email, FILTER_VALIDATE_EMAIL))
    $error ='ongeldige email';
    
    if($naamhond == '')
    $error ='naam hond invullen';
    
    if($ras == '')
    $error ='ras invullen';
    
    if($geslacht == '')
    $error ='geslacht invullen';
    
    if($geboortedatum == '')
    $error ='datum invullen';
    
    if($chipnummer == '')
    $error ='chip invullen';
    
    if($Inentingen == '')
    $error ='enting invullen';
    
    if($cursus == '')
    $error ='cursus invullen';
    
    if($akkoord == '')
    $error ='voor akkoord invullen';
    
    if($lid == '')
    $error ='voor lid invullen';    
        
    return $error;
}


$contactpersoon = '';
$adres = '';
$postcode = '';
$plaats = '';
$telefoon = '';
$email = '';
$naamhond = '';
$ras = '';
$geslacht = '';
$geboortedatum = '';
$chipnummer = '';
$Inentingen = '';
$cursus = '';
$opmerking = '';
$akkoord = '';
$lid = '';

if($_SERVER['REQUEST_METHOD'] == 'POST')
{

        // formulier is verzonden.
                
    $contactpersoon = $_POST['contactpersoon'];
    $adres = $_POST['adres'];
    $postcode = $_POST['postcode'];
    $plaats = $_POST['plaats'];
    $telefoon = $_POST['telefoon'];
    $email = $_POST['email'];
    $naamhond = $_POST['naamhond'];
    $ras = $_POST['ras'];
    $geslacht = $_POST['geslacht'];
    $geboortedatum = $_POST['geboortedatum'];
    $chipnummer = $_POST['chipnummer'];
    $Inentingen = $_POST['Inentingen'];
    $cursus = $_POST['cursus'];
    $opmerking = $_POST['opmerking'];
    $akkoord = $_POST['akkoord'];
    $lid = $_POST['lid'];
        
        $error = validate($contactpersoon, $adres, $postcode, $plaats, $telefoon, $email, $naamhond, $ras, $geslacht, $geboortedatum, $chipnummer, $Inentingen, $cursus, $opmerking, $akkoord, $lid);
        
        if($error != '')
           echo $error;
         else
             if(sendemail($contactpersoon, $adres, $postcode, $plaats, $telefoon, $email, $naamhond, $ras, $geslacht, $geboortedatum, $chipnummer, $Inentingen, $cursus, $opmerking, $akkoord, $lid) == true)
                header('location: Bedankt_voor_uw_vertrouwen.html');
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aanmeldingformulier</title>
<style type="text/css">
<!--
.Kop1 {    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 16pt;
    font-style: normal;
    font-weight: bold;
    color: #000;
    text-align: center;
}
-->
</style>
</head>

<body>
<table width="750" border="0" cellpadding="0" id="table4" style="margin:0 15; border-collapse: collapse; text-align:center; text-indent:0; line-height:100%">
  <tr align="left" valign="top">
    <td height="447" align="right" bgcolor="#FFFFFF"><div align="left">
      <blockquote class="Kop1"><strong>AANMELDINGSFORMULIER</strong><br />
      </blockquote>
      <table width="750" border="0" cellpadding="0" id="table5" style="margin:0 15; border-collapse: collapse; text-align:center; text-indent:0; line-height:100%">
        <tr align="left" valign="top">
          <td height="447" align="right" bgcolor="#FFFFFF"><div align="left">
<form action="" method="post">
              <p align="left"><u><strong>Gegevens eigenaar</strong></u><strong>:</strong><br />
              </p>
              <table width="800" border="1">
                <tbody>
                  <tr>
                    <td><label for="contactpersoon">Contactpersoon:</label></td><td><input type="text" size="50" id="contactpersoon" name="contactpersoon" value="<?php echo $contactpersoon; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="adres">Adres:</label></td><td><input type="text" size="50" id="adres" name="adres" value="<?php echo $adres; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="postcode">Postcode:</label></td><td><input type="text" size="10" id="postcode" name="postcode" value="<?php echo $postcode; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="plaats">Plaats:</label></td><td><input type="text" size="50" id="plaats" name="plaats" value="<?php echo $plaats; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="telefoon">Telefoon:</label></td><td><input type="text" size="50" id="telefoon" name="telefoon" value="<?php echo $telefoon; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="email">Email:</label></td><td><input type="text" size="50" id="email" name="email" value="<?php echo $email; ?>"/></td>
                  </tr>
                </tbody>
              </table>
              <br />
              <p><u><strong>Gegevens hond</strong></u><strong>:</strong><br />
              </p>
              <table width="800" border="1">
                <tbody>
                  <tr>
                    <td><label for="naamhond">Naam:</label></td><td><input type="text" size="50" id="naamhond" name="naamhond" value="<?php echo $naamhond; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="ras">Ras:</label></td><td><input type="text" size="50" id="ras" name="ras" value="<?php echo $ras; ?>"/></td>
                  </tr>
                  <tr>
                    <td>Geslacht</td>
                    <td><label>
                      <input name="geslacht" type="radio" id="geslacht" value="Reu" <?php if($_POST['geslacht']=="Reu") echo "checked=checked"; ?> >
                      Reu</label>
                            <label>
                            <input name="geslacht" type="radio" id="geslacht" value="Teef" <?php if($_POST['geslacht']=="Teef") echo "checked=checked"; ?> > Teef
                              </label></td>
                      <br/><br/>
                  </tr>
                  <tr>
                    <td><label for="geboortedatum">Geboortedatum:</label></td><td><input type="text" size="50" id="geboortedatum" name="geboortedatum" value="<?php echo $geboortedatum; ?>"/></td>
                  </tr>
                  <tr>
                    <td><label for="chipnummer">Chipnummer:</label></td><td><input type="text" size="50" id="chipnummer" name="chipnummer" value="<?php echo $chipnummer; ?>"/></td>
                  </tr>
                  <tr>
                    <td>Inentingen</td>
                    <td><label>
                      <input name="Inentingen[]" type="checkbox" value="enting1"/> Enting 1</label>
                            <label>
                      <input name="Inentingen[]" type="checkbox" value="enting2"/> Enting 2</label>
                            <label>
                      <input name="Inentingen[]" type="checkbox" value="enting3"/> Enting 3</label>
                            <label>
                      <input name="Inentingen[]" type="checkbox" value="kennelhoest"/> Kennelhoest</label>
                            <label>
                      <input name="Inentingen[]" type="checkbox" value="jaarlijks"/> Jaarlijks</label></td>
                  </tr>
                </tbody>
              </table>
              <p><strong><u>Ik meld mij aan voor de volgende cursus:</u></strong><u></u><br />
                                    </p>
              <table width="200" border="1">
                <tbody>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="puppy"/> Puppycursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="basis"/> Basiscursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="sgh"/> SGHcursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="shh"/> SHHcursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="sgg"/> SGGcursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="behendigheid"/> Behendigheidcursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="vzh"/> VZHcursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="ipo"/> IPOcursus</label></td>
                  </tr>
                  <tr>
                    <td><label>
                      <input name="cursus[]" type="checkbox" value="speuren"/> Speuren</label></td>
                  </tr>
                </tbody>
              </table>
              <p><u><strong>Bijzonderheden:</strong></u></p>
              <table width="600" border="1">
                <tbody>
                  <tr>
                    <td><label>
                      <textarea name="opmerking" rows="5" cols="100"><?php echo $_POST['opmerking']; ?></textarea>      
                    </label></td>
                  </tr>
                </tbody>
              </table>
              <p>
                 <input name="akkoord" type="checkbox" value="ja" id="akkoord" <?php if(isset($_SESSION['input']['akkoord']) && $_SESSION['input']['akkoord'] == ja) echo 'checked="checked"'; ?>
            />
            <label>Ja ik ga akkoord met het <a href="Organisatie/HHreglement.html" target="_blank">huishoudelijk reglement</a>.</label>
                           (Zonder akkoord wordt dit formulier niet verstuurd.) <br />
              </p>
              <p>
                <label>
                  <input name="lid" type="radio" value="Ja" <?php if($_POST['lid']=="ja") echo "checked=checked"; ?>/>Ja</label><label><input name="lid" type="radio" value="Nee" <?php if($_POST['lid']=="nee") echo "checked=checked"; ?>/>Nee, ik wil voor &euro; 120,00 per jaar (excl adm./inschrijfkosten) lid worden van H.D.C. de Loop.</label>
                <br />
                <br />
              </p>
              <table width="150">
                <tbody>
                  <tr>
                    <td><label>
                      <input id="Reset" type="reset" value="Reset " name="Reset" />
                    </label></td>
                    <td><input type="submit" value="Reactie verzenden" /></td>
                  </tr>
                </tbody>
              </table>
              <p>&nbsp;</p>
            </form>
          </div></td>
        </tr>
      </table>
      <blockquote>
        <p>&nbsp;</p>
      </blockquote>
    </div></td>
  </tr>
</table>
</body>
</html>


- Aar -:
Gelieve in het vervolg bij code de [code][/code]-tags gebruiken, en probeer dit te beperken tot relevante code t/m 20 regels.
Alvast bedankt!
Gewijzigd op 08/03/2014 00:54:01 door - Ariën -
 
PHP hulp

PHP hulp

25/04/2024 07:00:19
 
- SanThe -

- SanThe -

07/03/2014 22:48:15
Quote Anchor link
Moet dat uitroepteken niet weg in regel 43?

if(!$mail->send()) {
 
Marco Moens

Marco Moens

08/03/2014 08:24:19
Quote Anchor link
yes, top heel erg bedankt
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.