{"action":"created","issue":{"url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/581","labels_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/581/labels{/name}","comments_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/581/comments","events_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/581/events","html_url":"https://github.com/PHPMailer/PHPMailer/issues/581","id":121387753,"number":581,"title":"Mailer Error: SMTP connect() failed","user":{"login":"tylerimmel5","id":16233853,"avatar_url":"https://avatars.githubusercontent.com/u/16233853?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerimmel5","html_url":"https://github.com/tylerimmel5","followers_url":"https://api.github.com/users/tylerimmel5/followers","following_url":"https://api.github.com/users/tylerimmel5/following{/other_user}","gists_url":"https://api.github.com/users/tylerimmel5/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerimmel5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerimmel5/subscriptions","organizations_url":"https://api.github.com/users/tylerimmel5/orgs","repos_url":"https://api.github.com/users/tylerimmel5/repos","events_url":"https://api.github.com/users/tylerimmel5/events{/privacy}","received_events_url":"https://api.github.com/users/tylerimmel5/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-10T02:30:56Z","updated_at":"2015-12-10T12:40:15Z","closed_at":"2015-12-10T07:28:40Z","body":"I recently tried setting up phpmailer with an smtp server with gmail and wamp, but I have failed numerous times. I have used hmailserver as well but there were multiple authentication errors with it so I switched to phpmailer. Phpmailer is having connection issues though and I am uncertain how to read the debugging info in order to determine what my problem is and from there how to fix it. My file info is here:\r\n\r\n```php\r\n<?php\r\nrequire 'phpmailer/PHPMailerAutoload.php';\r\n\r\n$mail = new PHPMailer;\r\n\r\n$mail->SMTPDebug = 2;                               // Enable verbose debug output\r\n\r\n$mail->isSMTP();                                      // Set mailer to use SMTP\r\n$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers\r\n$mail->SMTPAuth = true;                               // Enable SMTP authentication\r\n$mail->Username = 'secret@gmail.com';                 // SMTP username\r\n$mail->Password = 'secret';                           // SMTP password\r\n$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted\r\n$mail->Port = 587;                                    // TCP port to connect to\r\n\r\n$mail->setFrom('secret@gmail.com', 'Mailer');\r\n$mail->addAddress('secret@gmail.com', 'Joe User');     // Add a recipient\r\n$mail->addAddress('ellen@example.com');               // Name is optional\r\n$mail->addReplyTo('info@example.com', 'Information');\r\n$mail->addCC('cc@example.com');\r\n$mail->addBCC('bcc@example.com');\r\n\r\n$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments\r\n$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name\r\n$mail->isHTML(true);                                  // Set email format to HTML\r\n\r\n$mail->Subject = 'Here is the subject';\r\n$mail->Body    = 'This is the HTML message body <b>in bold!</b>';\r\n$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';\r\n\r\nif(!$mail->send()) {\r\n    echo 'Message could not be sent.';\r\n    echo 'Mailer Error: ' . $mail->ErrorInfo;\r\n} else {\r\n    echo 'Message has been sent';\r\n}\r\n?>\r\n```\r\nDebug output:\r\n```\r\n2015-12-10 05:28:23 Could not access file: /var/tmp/file.tar.gz\r\n2015-12-10 05:28:23 Could not access file: /tmp/image.jpg\r\n2015-12-10 05:28:23 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP w75sm5140764qka.25 - gsmtp\r\n2015-12-10 05:28:23 CLIENT -> SERVER: EHLO localhost\r\n2015-12-10 05:28:23 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [72.9.9.76] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8\r\n2015-12-10 05:28:23 CLIENT -> SERVER: STARTTLS\r\n2015-12-10 05:28:23 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS\r\n2015-12-10 05:28:23 CLIENT -> SERVER: EHLO localhost\r\n2015-12-10 05:28:23 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [72.9.9.76] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8\r\n2015-12-10 05:28:23 CLIENT -> SERVER: AUTH LOGIN\r\n2015-12-10 05:28:23 SERVER -> CLIENT: 334 xxx\r\n2015-12-10 05:28:23 CLIENT -> SERVER: xxx==\r\n2015-12-10 05:28:23 SERVER -> CLIENT: 334 xxx\r\n2015-12-10 05:28:23 CLIENT -> SERVER: xxx\r\n2015-12-10 05:28:24 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257 w75sm5140764qka.25 - gsmtp\r\n2015-12-10 05:28:24 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257 w75sm5140764qka.25 - gsmtp\r\n2015-12-10 05:28:24 SMTP Error: Could not authenticate.\r\n2015-12-10 05:28:24 CLIENT -> SERVER: QUIT\r\n2015-12-10 05:28:24 SERVER -> CLIENT: 221 2.0.0 closing connection w75sm5140764qka.25 - gsmtp\r\n2015-12-10 05:28:24 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer\r\nError: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting\r\n```\r\nSome of it I realize is a result of there being 'secret' instead of my actual email account and password but it still fails even with a correct email and password. "},"comment":{"url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/comments/163598643","html_url":"https://github.com/PHPMailer/PHPMailer/issues/581#issuecomment-163598643","issue_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/581","id":163598643,"user":{"login":"Synchro","id":81561,"avatar_url":"https://avatars.githubusercontent.com/u/81561?v=3","gravatar_id":"","url":"https://api.github.com/users/Synchro","html_url":"https://github.com/Synchro","followers_url":"https://api.github.com/users/Synchro/followers","following_url":"https://api.github.com/users/Synchro/following{/other_user}","gists_url":"https://api.github.com/users/Synchro/gists{/gist_id}","starred_url":"https://api.github.com/users/Synchro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Synchro/subscriptions","organizations_url":"https://api.github.com/users/Synchro/orgs","repos_url":"https://api.github.com/users/Synchro/repos","events_url":"https://api.github.com/users/Synchro/events{/privacy}","received_events_url":"https://api.github.com/users/Synchro/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T12:40:15Z","updated_at":"2015-12-10T12:40:15Z","body":"Really, you don't have a connection problem. If you did you would not be seeing any SMTP conversation. You have exactly the auth problem described in both links. Either enable less secure apps or implement xoauth2."}}