Wellicht is dit al eens voorbij gekomen, maar kon niets vinden wat specifiek met dit probleem te maken heeft:
Ik vertel even in het kort mijn stappen zoals tot nu gevolgd:
-zipfile gedownload op
-Bestanden uit de zipfile uitgepakt in map phpmailer (op server)
-php bestand aangemaakt als: mailer.php (zie onderstaande code)
-smtp configuratie aangepast in mail.php (gebruik smtp server: smtp.kpnmail.nl (zie voorbeeldcode hieronder)
-Bestand mail.php op server gezet.
Bij het aanroepen via de browser (www.mijnwebsite.nl/mail.php) verschijnt foutmelding:
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
wat heb ik al geprobeerd:
-gebruik te maken van andere smtp server (gmail)
-verschillende poortnummers gebruikt (464 / 25)
-documentatie nagezien volgens de link uit de foutnmelding:
Ondanks dit blijft dezelfde foutmelding bestaan. Ik begrijp eruit dat het bestand mail.php geen connectie kan krijgen met de smtp server. echter kan ik niets ontdekken waaraan dit ligt. Wie kan wat advies geven?
mailer.php
<?
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 1; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.kpnmail.nl'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'Ho');
$mail->addAddress('[email protected]', 'test'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>