2 Replies - 10492 Views - Last Post: 03 June 2009 - 09:22 PM Rate Topic: -----

#1 peihwa330   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 15-March 07

sending mail using gmail server

Posted 02 June 2009 - 08:58 PM

hi, i'm trying to have a mail function using gmail server but i keep getting the error :
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

this is the code i got

<?php
include("class.phpmailer.php");
include("class.smtp.php");

if(isset($_POST['send'])){
	$body=$_POST[email];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth   = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // use ssl
$mail->Host = "ssl://smtp.gmail.com"; // GMAIL's SMTP server
$mail->Port  = 465; // SMTP port used by GMAIL server
$mail->Username   = "[email protected]"; // GMAIL username
$mail->Password   = "mypassword"; // GMAIL password
$mail->AddReplyTo("[email protected]","FirstName LastName"); // Reply email address
$mail->From = "[email protected]";
$mail->FromName = "myname"; // Name to appear once the email is sent
$mail->Subject = "testing 123"; // Email's subject
//$mail->Body = "Hello World,<br />This is the HTML BODY<br />"; //HTML Body
$mail->AltBody = "This is a test email"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body); // [optional] Send body email as HTML
$mail->AddAddress("[email protected]");  // email address of recipient
//$mail->AddAttachment("files/files.zip"); // [optional] attachment
$mail->IsHTML(true); // [optional] send as HTML
if(!$mail->Send())
echo "Mailer Error: " . $mail->ErrorInfo;
else
echo "Message sent!";
}
?>



** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: sending mail using gmail server

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3837
  • View blog
  • Posts: 13,994
  • Joined: 08-August 08

Re: sending mail using gmail server

Posted 03 June 2009 - 05:28 AM

From:
http://www.community...e...3&cid=AF0CE

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server


Was This Post Helpful? 0
  • +
  • -

#3 peihwa330   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 15-March 07

Re: sending mail using gmail server

Posted 03 June 2009 - 09:22 PM

I had try on the link you suggested. Somehow, the main problem is my Mercury and I followed the configuration with the guidance from :

http://www.zoe.vc/20...en/?lan=english

but I still could not get it right. When i tried to send email from Mercury, Mercury SMTP client(relay version) always stated :

error in connection handshake with smtp.gmail.com OR
fail.Error FF servicing queue job.(when I had change the port to 587.)

Based on the error FF servicing queue job, I found the soultion from : http://objectmix.com...r-mercurye.html but it did not work also.

Is there any other way to solve it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1