ich versuche, phpMailer zu verwenden, um Bestätigungsnachrichten per E-Mail an Benutzer zu senden. Mein Code lautet:
<?php
include("class.phpmailer.php");
include("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server
$mail->Port = 465; // set the port to use
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // your SMTP username or your gmail username
$mail->Password = "mypasswrord"; // your SMTP password or your gmail password
$from = "[email protected]"; // Reply to this email
$to="[email protected]"; // Recipients email ID
$name="Jersey Name"; // Recipient's name
$mail->From = $from;
$mail->FromName = "Webmaster"; // Name to indicate where the email came from when the recepient received
$mail->AddAddress($to,$name);
$mail->AddReplyTo($from,"Webmaster");
$mail->WordWrap = 50; // set Word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Sending Email From Php Using Gmail";
$mail->Body = "This Email Send through phpmailer, This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
ich habe bereits ssl in php.ini aktiviert.
PS> [email protected] ist eine Masken-E-Mail zum Schutz der Privatsphäre. Aber ich habe in diesem Teil eine echte E-Mail-Adresse angegeben
in Ihrer php.ini stellen Sie sicher, dass Sie die Zeile mit kommentiert haben
extension=php_openssl.dll
Aktivieren Sie einfach den extension=php_openssl.dll
und befolgen Sie diese Anweisungen auf diesem Link
Ich habe getestet, es funktioniert 100%.
falsch:
$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server
gut:
$mail->Host = "smtp.gmail.com"; // specify main and backup server
Von hier
2) Kommentieren Sie die folgenden Codezeilen in class.phpmailer.php aus
/*
if(strstr($hosts[$index], ":"))
list($Host, $port) = explode(":",
$hosts[$index]); else
*/
Versuchen Sie dies, wenn Sie noch nicht sind.
Diese Seite hat Code, den der Autor behauptet "funktionierte einwandfrei".
Der einzige wirkliche Unterschied, den ich zwischen seinem und Ihrem sehe, ist, dass er Folgendes hat:
$mail->Mailer = "smtp";
Ich denke, ich würde mit seinem Code genau beginnen, um zu sehen, ob es funktioniert, und dann von dort aus debuggen.