Hallo,
Ik ben bezig met het opzetten van een php mail script om de variabelen uit een formulier door te sturen naar mijn mail.
Ik heb het script wel werkend alleen komt in de mail alles achter elkaar te staan i.p.v. alles geordend onder elkaar. het is waarschijnlijk een kleinigheidje maar ik kom er niet achter..
alvast bedankt!
Ik ben bezig met het opzetten van een php mail script om de variabelen uit een formulier door te sturen naar mijn mail.
Ik heb het script wel werkend alleen komt in de mail alles achter elkaar te staan i.p.v. alles geordend onder elkaar. het is waarschijnlijk een kleinigheidje maar ik kom er niet achter..
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
| <html> <head><title>PHP Mail Sender</title></head> <body> <?php /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */ $reply_mail = $HTTP_POST_VARS['mail_adress']; $subject = $HTTP_POST_VARS['subject']; $name = $HTTP_POST_VARS['name']; $email = "info@tiemensensteenwoerd.nl"; $phone_nmmr = $HTTP_POST_VARS['phone_nmmr']; $message = $HTTP_POST_VARS['message']; $headers = "From: ".$NAME." <".$reply_mail.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "Return-Path: Mail-Error <martin@focusdigital.nl>\r\n"; $headers .= "Reply-To: ".$name." <".$reply_mail.">\r\n"; $mailbody = " Naam: $name \n E-mailadres: $reply_email \n Telefoonnummer: $phone_nmmr \n Bericht: $message \n deze mail is automatisch gegenereerd en verstuurd.\n "; /* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */ if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif ($subject == "") { echo "<h4>No subject</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */ elseif (mail($email,$subject,$mailbody,$headers)) { echo "<h4>uw gegevens zijn verstuurd, u krijgt zo spoedig mogelijk bericht</h4>"; } else { echo "<h4>uw gegevens kunnen niet verstuurd worden naar $email</h4>"; } ?> </body> </html> |
alvast bedankt!
MRTN