<?php
require_once('/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.tonneurd.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.tonneurd.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected] "; // SMTP account username
$mail->Password = "------"; // SMTP account password
$mail->SetFrom('[email protected] ', 'First Last');
$mail->AddReplyTo("[email protected] ","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
$mail->Body($message);
$address = "[email protected] ";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Dus zo moet die kloppen?
EDIT: De submit knop geeft geen actie. Waar kan deze fout uit voortkomen? Uit de html?
Link gekopieerd
Je controleert niet of er gePOST is.
Link gekopieerd
- Aar - op 11/02/2014 17:23:08
Je controleert niet of er gePOST is.
Sorry hoor maar snap er geen knikker meer van, vandaar dat ik het ook hier geplaatst heb.
Link gekopieerd
Ariën
11-02-2014 17:34
gewijzigd op 11-02-2014 17:35
Dan raad ik je aan om eens de beginnertutorial van
www.phptuts.nl te bekijken en de voorbeelden uit te proberen.
Of laat het uitbesteden, zoals ik al eerder zei...
Link gekopieerd
<?php
require_once('/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.tonneurd.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.tonneurd.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected] "; // SMTP account username
$mail->Password = "-----"; // SMTP account password
$mail->SetFrom('[email protected] ', 'First Last');
$mail->AddReplyTo("[email protected] ","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
if(isset($_POST[$name]))
{
if(isset($_POST[$email]))
{
if(isset($_POST[$comments]))
{
$mail->Body($message);
$address = "[email protected] ";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Link gekopieerd
Je kan ook lukraak wat PHP-code toevoegen, maar ik heb eigenlijk niet echt het idee dat je mijn advies hebt opgevolgd.
Link gekopieerd