Goededag iedereen,

Omdat ik zelf niet verder kom heb ik graag de hulp nodig voor een contact formulier.
De HTML basis heb ik al, nu moet deze gecombineerd worden met PHPmailer en krijg het maar niet aan de praat.

Geintereseerd?
Je kan me mailen op: [email protected]

Met vriendelijke groet,
Tonny-Boy Verweij
<?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?
Je controleert niet of er gePOST is.
- 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.
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...

<?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!";
}
?>
Je kan ook lukraak wat PHP-code toevoegen, maar ik heb eigenlijk niet echt het idee dat je mijn advies hebt opgevolgd.

Reageren