4

For the past 2 hours I've been looking online to see if any other people encountered this problem, and it seems a lot has, bot none of the answers are working for me.

SMTP -> FROM SERVER:220 mx.google.com ESMTP vq7sm928004oeb.13 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [50.57.114.141] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES 
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [50.57.114.141] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES 
SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 vq7sm928004oeb.13 
SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 vq7sm928004oeb.13 
The following From address failed: my@email.com

$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMPTAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 587;
$mail->Username = "my@email.com";
$mail->Password = "password";

I've tried almost every setting for PHPMailer, but can't figure out what's still going wrong, are there any server settings I need to take care of?

I also tried the normal php mail() function, but that's not sending mail either, although when using Drupal forms it just sends an email.

woutr_be
  • 9,532
  • 24
  • 79
  • 129

5 Answers5

10

For first you must configure the correct server to send emails (see at gmail.com):

SMTP server address: smtp.gmail.com
SMTP user name: Your full Gmail address (e.g. example@gmail.com)
SMTP password: Your Gmail password
SMTP port: 465 or 587
SMTP TLS/SSL required: yes

In PHPMailer:

$mail->SMTPAuth = true; // There was a syntax error here (SMPTAuth)
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 465;
$mail->Username = "YOU@gmail.com";
$mail->Password = "YOUR_GMAIL_password";
Community
  • 1
  • 1
kingmo
  • 133
  • 1
  • 6
  • If I try it with port 465 I'm getting the following: `SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> NOTICE: EOF caught while checking if connectedThe following From address failed: gmail@domain.com` – woutr_be Jan 11 '13 at 02:02
5

My problem was that I use the 2-step verification. So I had to remember to go to Authorised Access for my Google Account & then assign a Application-specific passwords for the domain that I'm using to send the mail.

Mike Gifford
  • 641
  • 1
  • 8
  • 17
2

The suggested port+protocol-combination seems wrong to me, because it's different to the official phpMailer-wiki:

Don't mix up these modes; ssl on port 587 or tls on port 465 will not work.

In PHPMailer:

$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 587; //use port 465 when using SMPTSecure = 'ssl'
$mail->Username = "YOU@gmail.com";
$mail->Password = "YOUR_GMAIL_password";
Smittie
  • 489
  • 6
  • 11
1

Just noticed I typed SMTP wrong in this line $mail->SMPTAuth = true;, correcting this solved my problem.

woutr_be
  • 9,532
  • 24
  • 79
  • 129
0

Setting up mail in php can be quite hard. have you tried using port=25?

  • Same problem, it always says "FROM SERVER:530-5.5.1 Authentication Required", does this not work with Google Apps addresses? – woutr_be Jan 11 '13 at 02:05