Senden Sie E-Mail mit der GMail-SMTP-server von einem PHP-Seite

Ich bin versucht, senden Sie eine E-Mail über den GMail-SMTP-server eine PHP-Seite, aber ich bekomme diese Fehlermeldung:

authentication failure [SMTP: SMTP-server unterstützt Authentifizierung (code: 250, Antwort: mx.google.com zu Ihren Diensten, [98.117.99.235] GRÖßE 35651584 8BITMIME STARTTLS-ENHANCEDSTATUSCODES PIPELINING)]

Kann jemand helfen? Hier ist mein code:

<?php
require_once "Mail.php";

$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "smtp.gmail.com";
$port = "587";
$username = "[email protected]";
$password = "testtest";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?>

InformationsquelleAutor skb | 2009-04-03

Schreibe einen Kommentar