Jump to content

PHPMailer issues


Oz

Recommended Posts

Firstly I'd like to say a hello to everyone, I've just registered an account here at PHPFreaks although I have used the tutorials in the past, I have never used the forums - something that I hope to change starting now ;)

 

OK, I'm having a problem with my PHPMailer setup. My aim is to have a registration email sent to a user upon sign up from ([email protected]). Now to reach this end I'm using a googleapps account and I have set up my mail servers set up correctly in my DNS (using ZoneEdit), so I can send/recieve mail from ([email protected]).

 

I am using PHPMailer (Version 2.1 Release for PHP5), and am using the following code (the gmail example script):

 

<?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

include("class.phpmailer.php");
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body             = $mail->getFile('contents.html');
$body             = eregi_replace("[\]",'',$body);

$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
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server

$mail->Username   = "[email protected]";  // GMAIL username
$mail->Password   = "****";            // GMAIL password

$mail->AddReplyTo("[email protected]","My Domain");

$mail->From       = "[email protected]";
$mail->FromName   = "My Domain";

$mail->Subject    = "PHPMailer Test Subject via gmail";

$mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body
//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap   = 50; // set word wrap

$mail->MsgHTML($body);

$mail->AddAddress("[email protected]", "Firstname Lastname");

//$mail->AddAttachment("images/phpmailer.gif");             // attachment

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

 

I set up a PHP document to test this mail feature, but every time I load it, it displays this error: Mailer Error: SMTP Error: Could not connect to SMTP host.

 

For the past 3 days I've tried everything that is returned from my searches on google, and right now I have no more ideas or resources for help. So I'm typing this with fingers crosses that someone has run into this problem before (or knows of someone who has) and could point me towards a solution.

 

Thanks for your time guys, hope someone can get back to me soon!

 

Oz

 

 

PS: I love the new layout, how long has it been like this?

Link to comment
https://forums.phpfreaks.com/topic/109227-phpmailer-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.