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 (admin@mydomain.com). 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 (admin@mydomain.com).

 

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   = "admin@mydomain.com";  // GMAIL username
$mail->Password   = "****";            // GMAIL password

$mail->AddReplyTo("admin@mydomain.com","My Domain");

$mail->From       = "admin@mydomain.com";
$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("user@userdomain.com", "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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.