Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: kevinburke (59.95.175.---)
Date: April 09, 2010 10:04AM

Hello,
I'm trying to use Wamp to send an email. When I run this script the page loads and my error log says that Mail/mail.php times out. I'm only sending the email to one person and i'm curious what the problem is. I would really appreciate your help. Other combinations of SMTP port as 25 and smtp as localhost don't work, they say failed to connect to mailserver. Again, thanks for helping me out.

Here's the script - I'm running this by opening the page in my browser.
<?php


ini_set("include_path", ".;C:\wamp\bin\php\php5.3.0\PEAR"winking smiley;
ini_set("smtp_port", 465);
ini_set("SMTP", "smtp.gmail.com"winking smiley;
ini_set("sendmail_from", "kburke11@students.claremontmckenna.edu"winking smiley;
ini_set("auth_username", "kburke11@students.claremontmckenna.edu"winking smiley;
ini_set("auth_password", "mypassword"winking smiley;
$m = include('Mail.php');

include('Mail/mime.php');

ini_set('memory_limit','1000M');

$text = 'Text version of email';
$html = 'Hello!';
$crlf = '\r\n';


echo 'This is working so far';

$hdrs = array(
'From' => 'kburke11@cmc.edu',
'Subject' => 'Test html message'
);

echo 'This is working so far';

$mime = new Mail_mime();
print_r($mime);
echo 'This is working so far2';

$mime->setTXTBody($text);
$mime->setHTMLBody($html);

//do not ever try to call these lines in reverse order
$body = $mime->get();
$hdrs = $mime->headers($hdrs);

echo 'This is working so far2';

$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "kburke11@students.claremontmckenna.edu";
$password = "mypassword";


$mail =& Mail::factory('mail',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password,
'debug' => TRUE));

echo 'This is working so far3';


$recipient = array('kburke11@cmc.edu');

if (PEAR::isError($mail->send($recipient, $hdrs, $body))) {
die("Couldn't send mail"winking smiley;
}

echo $result;



?>

Options: ReplyQuote
Re: Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: yfastud (Moderator)
Date: April 09, 2010 02:58PM


Options: ReplyQuote
Re: Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: kevinburke (59.95.165.---)
Date: April 12, 2010 07:37AM

Thanks for replying.

If I understand correctly, I'm not using WAMP to send mail but instead I am using Google's mail server.

This post seems to suggest that it's possible:

[crazzycoder.blogspot.com]
[www.programmingfacts.com]

Would appreciate your help,

Kevin

Options: ReplyQuote
Re: Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: showstopper (---.rev.greendottt.net)
Date: April 12, 2010 12:19PM

there is a way how to set up your server t send mail through gmail i'll post a link to the guide

Options: ReplyQuote
Re: Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: showstopper (---.rev.greendottt.net)
Date: April 12, 2010 01:04PM

Here is the (link hidden; see below)



Edited 1 time(s). Last edit at 04/12/2010 02:35PM by yfastud.

Options: ReplyQuote
Re: Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: yfastud (Moderator)
Date: April 12, 2010 02:36PM

showstopper, if you want to help kevinburke, pm the link to him but we appreciate it if you do NOT post the link in this forums since anyone can try it and if they have ANY problem, they would come back here and it really affect the reputation of wampserver

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Trying to send SMTP mail through pear mail, Gmail account - connection times out
Posted by: showstopper (---.rev.greendottt.net)
Date: April 12, 2010 02:46PM

ok no prob

Options: ReplyQuote


Sorry, only registered users may post in this forum.