2016-05-31 4 views
-1

Gibt es etwas, das mir fehlt? Ich habe hoch und niedrig gesucht und bin mir nicht sicher, was mit meinem Code nicht stimmt. Ist es auch, dass ich öffentliche statt Mail benutze?SMTP Mit Google Mail-Fehler. Ich erhalte die E-Mail nicht

<?php 
require_once('phpmailer.php'); 
class Mail extends PhpMailer 
{ 
    // Set default variables for all new objects 
    public $mail  = IsSMTP; 
    public $From  = '[email protected]'; 
    public $FromName = SITETITLE; 
    public $Host  = 'smtp.gmail.com'; 
    public $port  = 587; 
    public $Mailer = 'smtp'; 
    public $SMTPAuth = true; 
    public $Username = '[email protected]'; 
    public $Password = 'password'; 
    public $SMTPSecure = 'tls'; 
    public $WordWrap = 75; 

    public function subject($subject) 
    { 
     $this->Subject = $subject; 
    } 

    public function body($body) 
    { 
     $this->Body = $body; 
    } 

    public function send() 
    { 
     $this->AltBody = strip_tags(stripslashes($this->Body))."\n\n"; 
     $this->AltBody = str_replace("&nbsp;", "\n\n", $this->AltBody); 
     return parent::send(); 
    } 
} 

Dies ist mein aktueller Code, und das Problem wurde nicht gelöst. Irgendwelche neuen Ideen?

+0

ich beide 587 versucht habe, und 465. – Jayy

+0

Mögliche Duplikat von [PHPMailer SMTP ERROR: Verbindung zum Server konnte nicht hergestellt werden] (http://stackoverflow.com/questions/36351817/phpmailer-smtp-error-failed-to-connect-to-server) – brimstone

+0

kann nicht einfach verwendet werden Google Mail-Server, um Leute zu spammen. – user2260040

Antwort

0

Höchstwahrscheinlich ein Port.

public $port  = '4587'; 

if you tried configuring your SMTP server on port 465 (with SSL/TLS) and port 587 (with STARTTLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL/TLS).

Apple Mail users: At times, Mail may misinterpret your SMTP server settings. If you currently have 'smtp.gmail.com:[email protected]' in the 'Outgoing Mail Server:' field of your settings, please try changing the field to 'smtp.gmail.com' and saving your settings.

https://support.google.com/mail/answer/78775?hl=en

Sie gemischt 465 und 587 Ports.

Wenn es immer noch nicht funktioniert, können Sie versuchen, Verbindung zu debuggen. Siehe zum Beispiel PHPMailer only sends email when SMTPDebug = true.

Auch aus Dokumentation:

/** 
* SMTP class debug output mode. 
* Debug output level. 
* Options: 
* * `0` No output 
* * `1` Commands 
* * `2` Data and commands 
* * `3` As 2 plus connection status 
* * `4` Low-level data output 
* @var integer 
* @see SMTP::$do_debug 
*/ 
public $SMTPDebug = 0; 

Verwenden Sie es, um herauszufinden, was Problem sein kann. Es wird dir sagen, wo es aufhört.

+0

Behoben, aber immer noch nichts – Jayy

+0

Debugging überprüfen - aktualisiert answear – Grzegorz

0

Hafen sollte statt 4587.

Hier sind die Standard-Google Mail SMTP-Einstellungen sein;

  • Gmail SMTP-Server-Adresse: smtp.gmail.com
  • Gmail SMTP-Benutzername: Ihre vollständige Google Mail-Adresse (zB [email protected])
  • Gmail SMTP Passwort: Ihr Google Mail-Passwort
  • Gmail SMTP-Port (TLS): 587
  • Gmail SMTP-Port (SSL): 465
  • Gmail SMTP TLS/SSL erforderlich: ja

und könnten Sie bitte die Linie

public $mail = 'IsSMTP()' 

mit folgenden Änderung:

+0

Sie möchten Google Mail-Anmeldeinformationen an smtp.mandrillapp.com senden? – zerkms

+0

@zerkms Ich habe mich wegen des Gastgebers geirrt. –

+0

Bearbeitet, und erhielt keine positiven Ergebnisse – Jayy

0

ändert Port gesichert einen für SMTP: 465

Verwandte Themen