1

I am attempting to send mail through my gmail account from a Dedicated Godaddy server. I have attempted to send email through my company's email server but Godaddy kills port 25 with no workaround (grrr).

I have searched high and low for a solution to this including here but am unable to send any emails. I always get an 'Authentication Required' error from google.

Here is the code I use to send the email:

include("Mail.php");

/* mail setup recipients, subject etc */

$headers["From"]   = "xxxxx@gmail.com";
$headers["to"]    = "yyyyy@hotmail.com";
$headers["subject"]   = "User feedback";   
$mailmsg    = "Hello, This is a test.";

/* SMTP server name, port, user/passwd */

$smtpinfo["host"]   = "ssl://smtp.gmail.com";   
$smtpinfo["port"]   = 465;    
$smtpinfo["auth"]   = true;    
$smtpinfo["username"]   = "xxxxx@gmail.com";
$smtpinfo["password"]   = "xxxxxx";
$smtpinfo["debug"]  = true;

/* Create the mail object using the Mail::factory method */

// $mail_object =& Mail::factory("smtp", $smtpinfo);
// EDIT -- removed reference   


$mail_object = Mail::factory("smtp", $smtpinfo);

/* Ok send mail */

$result = $mail_object->send($recipients, $headers, $mailmsg);

if(PEAR::isError($result))
{
 echo "\nerror sending mail: ".PEAR_Error::getCode().' '.PEAR_Error::getMessage();
}
else    
 echo "\nSuccessfully sent mail.";

Here is the response from pear mail:

DEBUG: Recv: 250-mx.google.com at your service, [208.109.190.226]
DEBUG: Recv: 250-SIZE 35651584
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250-AUTH LOGIN PLAIN XOAUTH
DEBUG: Recv: 250 ENHANCEDSTATUSCODES
DEBUG: Send: MAIL FROM:<xxxxx@gmail.com>

DEBUG: Recv: 530-5.5.1 Authentication Required. Learn more at
DEBUG: Recv: 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 t35sm1037116qco.30

Fatal error: Using $this when not in object context in /usr/share/php/PEAR.php on line 970

Any help is greatly appreciated.

Community
  • 1
  • 1
Patrick
  • 3,142
  • 4
  • 31
  • 46
  • Is your GMail account set to allow POP3? – drudge Nov 16 '10 at 22:30
  • the difference I can spot, is the use of references, remove the references, and try again? – ajreal Nov 16 '10 at 22:57
  • @jnpcl yes, my account has pop3 activated – Patrick Nov 17 '10 at 14:48
  • @ajreal i removed the only reference I found (at the Mail::factory) line, but still get the same error – Patrick Nov 17 '10 at 14:50
  • I spoke with Godaddy and they will not give me a list of blocked ports on the server. Idiot that I am, I thought with this being a dedicated server, I wouldn't have to worry about blocked ports. I ran this script on an a2hosting server and it completed successfully. I'm resigning myself to sending email the only way Godaddy will let me, through their own relay host, which may break my services... grrr – Patrick Nov 17 '10 at 18:41

2 Answers2

0

The problem is following code:

PEAR_Error::getCode().' '.PEAR_Error::getMessage();

Use

$result->getMessage()

and

$result->getCode()
cweiske
  • 30,033
  • 14
  • 133
  • 194
0

The solution is... there is no solution since Godaddy was doing blocking. No way to get around it so I ended up using their 'approved' mail delivery server. grrr.

Patrick
  • 3,142
  • 4
  • 31
  • 46