3 Replies - 1725 Views - Last Post: 27 February 2012 - 09:15 AM Rate Topic: -----

#1 nagarajbv   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-February 12

Error in sending mail from gmail in localdevelopment

Posted 27 February 2012 - 08:15 AM

<?php
//date_default_timezone_set('America/Toronto');

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

$mail             = new PHPMailer();


$body             = "Hi welcome to mail system";
//$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "mail.gmail.com"; // SMTP server
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$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->SetFrom('[email protected]', 'PRSPS');

//$mail->AddReplyTo("[email protected]', 'First Last");

$mail->Subject    = "testing mail from PHP";

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "[email protected]";
$mail->AddAddress($address, "user2");

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

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

?>




When i am executed this code i am getting following error.

SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (5)
The following From address failed: [email protected] Mailer Error: The following From address failed: [email protected]



Please any one help me and tell me is there any mistake in the code.

This post has been edited by Atli: 27 February 2012 - 08:18 AM
Reason for edit:: Fixed the [code] tags and replace the real email addresses with example values.


Is This A Good Question/Topic? 0
  • +

Replies To: Error in sending mail from gmail in localdevelopment

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: Error in sending mail from gmail in localdevelopment

Posted 27 February 2012 - 08:31 AM

Here you go.
Was This Post Helpful? 0
  • +
  • -

#3 nagarajbv   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-February 12

Re: Error in sending mail from gmail in localdevelopment

Posted 27 February 2012 - 09:05 AM

thanks Jacks i came to know solution........!


Once again thank u...
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: Error in sending mail from gmail in localdevelopment

Posted 27 February 2012 - 09:15 AM

Yeah, but did you actually GET THE POINT? If you get an error, guess what...someone else has probably encountered it before. So you copy and paste the error into a search engine (without information unique to your particular situation), search, and read the links to find how other people solved it.

If it's a really OBSCURE error, or a question about functionality, then you post on a forum.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1