wie zum senden von smtp-E-mail von localhost
Bekomme ich immer diese Meldung, wenn Sie versuchen, senden von E-Mails von meinem lokalen host.
SMTP Fehler: Konnte keine Verbindung zum SMTP-host. Nachricht konnte nicht gesendet werden.
Mailer Error: SMTP Fehler: Konnte keine Verbindung zum SMTP-host.
unten ist mein code: bitte helfen Sie
HTML:
<?php
//$email and $message are the data that is being
//posted to this page from our html contact form
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
//When we unzipped PHPMailer, it unzipped to
//public_html/PHPMailer_5.2.0
require("class.phpmailer.php");
$mail = new PHPMailer();
//set mailer to use SMTP
$mail->IsSMTP();
//As this email.php script lives on the same server as our email server
//we are setting the HOST to localhost
$mail->Host = "localhost"; //specify main and backup server
$mail->SMTPAuth = true; //turn on SMTP authentication
//When sending email using PHPMailer, you need to send from a valid email address
//In this case, we setup a test email account with the following credentials:
//email: [email protected]
//pass: password
$mail->Username = "[email protected]"; //SMTP username
$mail->Password = "Nov112014"; //SMTP password
//$email is the user's email address the specified
//on our contact us page. We set this variable at
//the top of this page with:
//$email = $_REQUEST['email'] ;
$mail->From = $email;
//below we want to set the email address we will be sending our email to.
$mail->AddAddress("[email protected]", "Usman Ali Siddiqui");
//set word wrap to 50 characters
$mail->WordWrap = 50;
//set email format to HTML
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website Etutionhub!";
//$message is the user's message they typed in
//on our contact us page. We set this variable at
//the top of this page with:
//$message = $_REQUEST['message'] ;
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
- Sie haben einen mail-server installiert?
- E-mail-server? Nein. Ich bin nur mit diesem code auf meinem localhost. Ich habe dies nicht möglich?
- Lesen Sie die Kommentare im code
- so installieren Sie mail-server?
- Ich denke, dies ist aufgrund der smtp-port-Nummer nicht korrekt konfiguriert .
Du musst angemeldet sein, um einen Kommentar abzugeben.
Öffnen Sie die
php.ini
. Für XAMPP, es befindet sich inC:\XAMPP\php\php.ini
. Finden Sie heraus, wenn Sie mit WAMP-oder LAMP-server.Hinweis: Machen Sie ein backup der
php.ini
Datei.Suche [mail function] in der php.ini-Datei.
Ändern Sie die localhost der name des smtp-Servers Ihres ISP ein. Keine Notwendigkeit zur änderung des
smtp_port
. Lassen Sie es als 25. Ändernsendmail_from
auspostmaster@localhost
um Ihre domain E-Mail-Adresse, die als Absenderadresse.Also für mich, es wird so werden wie diese.
Neustart des XAMPP oder WAMP(apache-server), so dass änderungen wird anfangen zu arbeiten.
Nun versuchen, schicken Sie die mail mit der
mail()
Funktion.Mail [email protected] von den localhost mit Betreff "Erfolg" und Körper "Großen" Localhost "funktioniert E-Mail".
Können Sie diese Zeile hinzufügen
$mail->SMTPSecure = "ssl";
nach