Failed to connect socket

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tanvirtonu
Forum Commoner
Posts: 35
Joined: Wed Oct 17, 2007 9:15 am

Failed to connect socket

Post by tanvirtonu »

I have written a simple php mailing script using mail peer. My code is as follows-

Code: Select all

<?php
require_once "Mail.php";
$from = "TAnvir Sender <bhonest_4ever2007@yahoo.com>";
$to = "Tonu Recipient <tanvirtonu@yahoo.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.mail.yahoo.com";
//$host = "smtp.mail.yahoo.com";

$port='465';
$username = "bhonest_4ever2007";
$password = "abcdefg";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
  	'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?>
Now I mgetting this error-

Failed to connect to ssl://smtp.mail.yahoo.com:465 [SMTP: Failed to connect socket: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (code: -1, response: )]
Pls help me.I m using an installer of Apache, MySQL and PHP for Windows called XAMPP 1.6.4 which is a Apache distribution for windows.I dont know how to recompile php with ssl. Bcos all I did to install php is I just installed Xampp installer.It did the rest.Help me.
phpBuddy
Forum Commoner
Posts: 37
Joined: Mon Nov 05, 2007 3:42 am

Post by phpBuddy »

hi

A question.
Who is your ISP internet provider?

Because this is domain of the smpt server you should use.

I have a broadband internet from my provider
and I send mail through the SMTP server of my ISP.
Just because I have an email account at hotmail or yahoo or http://www.operamail.com
this doesnt mean I can use them for my smtp send mail scripts.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The error suggests your build of PHP does not have OpenSSL installed.
tanvirtonu
Forum Commoner
Posts: 35
Joined: Wed Oct 17, 2007 9:15 am

Post by tanvirtonu »

phpBuddy wrote:hi

A question.
Who is your ISP internet provider?

Because this is domain of the smpt server you should use.

I have a broadband internet from my provider
and I send mail through the SMTP server of my ISP.
Just because I have an email account at hotmail or yahoo or http://www.operamail.com
this doesnt mean I can use them for my smtp send mail scripts.
If [s]u[/s] you [s]r[/s] are right then how can we read and write message using a mail client. I dont use the server and port no. of my ISP in my mail client.Still I can read and write message in yahoo mail by using their smtp and port(ssl). They work the same way as my script is doing. Why should I only depend on my ISP's smtp server ? What if I leave my area/country?As fas as I know , if [s]u[/s] you have any valid account in a server, [s]u[/s] you can use it from anywhere with that server name and that port.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.
thaynejo
Forum Newbie
Posts: 14
Joined: Tue Apr 01, 2008 9:06 am

Re:

Post by thaynejo »

I realize that I am bumping an old post that has probably been resolved. However, I feel that this is a common enough question, that I thought an answer would be good.
tanvirtonu wrote:If you are right then how can we read and write message using a mail client. I dont use the server and port no. of my ISP in my mail client.Still I can read and write message in yahoo mail by using their smtp and port(ssl). They work the same way as my script is doing. Why should I only depend on my ISP's smtp server ? What if I leave my area/country?As fas as I know , if you have any valid account in a server, you can use it from anywhere with that server name and that port.
Many ISP's have started doing what is known as SMTP blocking. In fact, it is rare now to find an ISP that does NOT do it. What occurs during SMTP blocking, is that the ISP directs ALL SMTP traffic through its mail servers. The purpose of doing this is to cut down on spam. If you are not authenticated through the ISP's SMTP server, you will not be able to send mail while connected to that ISP.

For example, my ISP is Verizon. When I am at home, I have to have my Outlook configured to use Verizon's SMTP server even though I do not use my Verizon email at all. When I go to my parent's home, they have Wild Blue as their ISP. I have to configure the Outlook on my laptop to use my their SMTP server.

This can get real annoying really fast if you travel a lot, but you can thank your local SPAM retailer for ISP's having to do this.

Anyway, I hope that answers some questions people may have about this.

Again, sorry about bumping the old post.
Post Reply