Krijg geen email binnen (Php code)
Heb code op computer, hoe zet ik dat in toppic?
Groet,
Pieter Hofstra
Gewijzigd op 11/08/2015 15:59:56 door Pieter Hofstra
Je zal het moeten versturen via een SMTP-server.
Of iets als dit volgen om het te laten werken.
https://www.youtube.com/watch?v=TO7MfDcM-Ho
Maar ik raadt je aan een PHP Library te gebruiken om dit voor je te regelen.
PHPmailer of Swiftmailer does the job well
Hoe kan ik de php code en het formulier laten zien in dit topic?
Ben net nieuw hier.
Groet,
Pieter Hofstra.
Je kan je php code plaatsen tussen speciale tags. Ze lijken een beetje op HTML.
Code (php)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
[ code ]
<?php
echo 'Hello World!';
?>
[ /code ]
[ /code ]
Wel moet je de spaties weghalen die ik in de code tags heb geplaatst.
<?php
echo 'Hello World!';
?>
[ /code ]
[ /code ]
Wel moet je de spaties weghalen die ik in de code tags heb geplaatst.
<div id="nieuwsbriefform">
<form id="form1" name="form1" method="post" action="Nieuwsbrief.php">
<div id="formnaam"><strong>Naam:</strong></div>
<div id="formbalk1">
<input name="naam" type="text" id="naam" size="36" />
</div>
<div id="formemail"><strong>
<label for="emailadres">Emailadres:</label>
</strong></div>
<div id="formbalk2">
<input name="emailadres" type="text" id="emailadres" size="36" />
</div>
<div id="aanmelden">
<input type="image" src="Afbeeldingen/Overige/Aanmelden.jpg" alt="verzenden" value="Verzenden" />
</div>
</form>
Php Code
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$naam = $_POST['naam'];
$emailadres = $_POST['emailadres'];
$to = "********@hotmail.com";
$subject = "Nieuwsbrief";
$message = "Ik wil graag de nieuwsbrief ontvangen.\n\nNaam: $naam\n\nEmailadres: $emailadres\n\n";
mail ($to, $subject,$message);
echo "Bericht is verzonden! <a href='index.html'>Klik hier</a> om terug te gaan";
?>
$naam = $_POST['naam'];
$emailadres = $_POST['emailadres'];
$to = "********@hotmail.com";
$subject = "Nieuwsbrief";
$message = "Ik wil graag de nieuwsbrief ontvangen.\n\nNaam: $naam\n\nEmailadres: $emailadres\n\n";
mail ($to, $subject,$message);
echo "Bericht is verzonden! <a href='index.html'>Klik hier</a> om terug te gaan";
?>
Zou dit moeten werken?
--
En ik zie echt hele oude technieken, waar haal je de code vandaan of is het nog iets ouds wat ergens op een server stond?
Ik zie nooit meer <input type="image"> langskomen eigenlijk.
HTML5 heeft <button>Hier uw tekst of afbeelding</button>
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
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
<?php
/**
* This example shows making an SMTP connection with authentication.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "mail.example.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "[email protected]";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
/**
* This example shows making an SMTP connection with authentication.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "mail.example.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "[email protected]";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Dit vraagt wel om de nodige portfowardings.
Gewijzigd op 11/08/2015 17:46:53 door Pipo Clown
...en zorgvuldige instelling! Je wilt zeker GEEN open relay voor spammers zijn waarna je ISP je deels zal blokkeren.