Keine Verbindung zu SMTP-server

Ich habe einen server mit mail-Unterstützung, sagen example.com. Ich konfiguriert den server und zusätzlichen MX-records über cpanel, so kann ich Emails senden und empfangen über outlook.com mit Adresse [email protected]. Die MX-records werden von domains.live.com.

Nun brauche ich, um E-mail senden programmgesteuert mithilfe von PHP über SMTP. Ich habe versucht, PHPmailer mit dem folgenden Skript. Aber es zeigt die Fehler

Mailer Error: SMTP Connect() failed. 

(Aber ich kann senden und empfangen E-Mails über outlook.com mit [email protected])

$body             = $_POST['message'];

$to = "[email protected]";
$from = '[email protected]';
$fName = 'first name';
$lName = 'last name';
$subject =  'my subject';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
  // $body             = eregi_replace("[\]",'',$body);
$mail->Host       = "mail.example.org"; //SMTP server example
$mail->SMTPDebug  = 0;           //enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;        //enable SMTP authentication
$mail->Port       = 25;          //set the SMTP port for the GMAIL server
$mail->Username   = "[email protected]"; //SMTP account username example
$mail->Password   = "password";
$mail->SetFrom($from, $fName.' '.$lName);
$mail->Subject = $subject;
$mail->AddAddress($to, "Support Team");
$mail->MsgHTML($body);

if(!$mail->Send()) {
     echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

Wie kann ich das Problem beheben.

Schreibe einen Kommentar