3

I am trying to create an email notification system with CI. The problem is the system on which I am working on has blocked gmail. So, i am unable to use the gmail SMTP. Now, I have to figure out a way to send emails with hotmail or any other SMTP services. Here is my code which worked for gmail but now for hotmail config/Email.php:

$config = array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.live.com',
    'smtp_port' => 587,
    'smtp_user' => 'muttalebr@hotmail.com',
    'smtp_pass' => 'XXXXXX',
    'charset' => 'utf-8',
 'newline' => "\r\n",
 'crlf' => "\r\n",
 'mailtype' => "html",


); 

the actual function that calls the email.php and send the email:

function sends($from,$to,$send,$user){
   $link=base_url()."index.php/anonymouscoll/cmembersarea/".$user;
   $emailmessage="Hello $to,<br />You have a new Gift from $from.<br />Click on the link:<a href=$link>$link</a> to check your gift.<br /><br /><br />Best Regards<br />Online Communication.";
   $this->load->library('email');
   $this->email->from('muttalebr@hotmail.com','Gift File');
   $this->email->to($send);
   $this->email->subject('You have a new Gift');
   $this->email->message($emailmessage);

   if($this->email->send()){
    echo "Email sent";

   }
   else{
    show_error($this->email->print_debugger());
   } 

Each time i call the ‘sends’ function i get the below error:

Severity: Warning

Message: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Filename: libraries/Email.php

Line Number: 1673 
and

Severity: Warning

Message: fsockopen() [function.fsockopen]: Failed to enable crypto

Filename: libraries/Email.php

Line Number: 1673 

I have also tried with

‘smtp_host’ => ‘sslv2://smtp.live.com’,

but it just wont work on my local machine. I am using windows 7 on my local machine and windows Xp for the system I will use the application[the one which blocked gmail]. I tried with both XAMPP ver 1.8.1 and WAMPP ver 2.2

Looking forward for your responses

~muttalebm

muttalebm
  • 552
  • 1
  • 6
  • 22

2 Answers2

1

The error because you didn't enable SSL in your php.info file. SO search how to enable to it . Otherwise you can look into my answer to the question in the below link which is same liek this. I faced this error when i am doing and i resolved it.

Reference Link

Community
  • 1
  • 1
Venkata Krishna
  • 4,287
  • 6
  • 30
  • 53
  • Hi venkat, thanks for your reply. I have open_ssl enabled and still facing the problem. Note the code works fine with gmail. The problem is that the server on which I am going to run my application does not allow gmail. So, I need to figure it out with an Microsoft account e.g. live,hotmail etc. But hotmail or live also does not work on my local machine. Please let me know if you have worked with hotmail smtp with ci – muttalebm Dec 06 '12 at 06:54
  • Hello again, i have tried with 465 it gives this Warning : fsockopen() [function.fsockopen]: SSL: crypto enabling timeout and fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.live.com:465 (Unknown error) – muttalebm Dec 06 '12 at 07:24
  • hey try with tls://smtp.live.com – Venkata Krishna Dec 06 '12 at 07:32
  • I am using windows 7 on my local machine and windows Xp for the system I will use the application[the one which blocked gmail]. I tried with both XAMPP ver 1.8.1 and WAMPP ver 2.2 – muttalebm Dec 06 '12 at 07:53
  • while i used tls://smtp.live.com i got the same warnings fsockopen() [function.fsockopen]: SSL: crypto enabling timeout and fsockopen() [function.fsockopen]: unable to connect to tls://smtp.live.com:465 (Unknown error) – muttalebm Dec 06 '12 at 07:59
  • can you do one thing go to your localhost and click on php info link in your xampp server and search for these things and let me know what are the results. Registered Stream Socket Transports,SSl Support, openSSl let me know what are you seeing against these in your php file......... – Venkata Krishna Dec 06 '12 at 08:07
  • Sorry for the delay, i had to go to my office. anyway here are the configurations i found from phpinfo. This is the machine whcih i am going to run the completed application. Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls OpenSSL support enabled OpenSSL support enabled OpenSSL Library Version OpenSSL 1.0.1c 10 May 2012 OpenSSL Header Version OpenSSL 0.9.8x 10 May 2012 OpenSSL support enabled – muttalebm Dec 06 '12 at 10:37
  • I searched your error in google i saw in one forum that guy tried in place of ssl in host name with sslv2 and it worked. U can try once – Venkata Krishna Dec 06 '12 at 10:46
  • Yes tried it as i have mentioned in my original post, i also googled around. Can you do me a favor and try the code by yourself? if it works for you then i will consider that the problem is in the serves which i am working on. Otherwise, i will have to drop the email function from my application :( – muttalebm Dec 06 '12 at 11:25
  • dude i also tried with my own code it's not working sorry may be it's a bug......... – Venkata Krishna Dec 06 '12 at 11:36
  • :'( that is a very sad news buddy. Thanks anyway for your help and time! – muttalebm Dec 06 '12 at 11:58
  • Any time your welcome and by the way in which company you work. I like to talk to u about work you are doing. I mean related to vacancies – Venkata Krishna Dec 06 '12 at 12:06
  • You can contact me at muttalebm@yahoo.com but you would not like where i am working as it has nothing to do with software development. I am working for Grameenphone as a customer manager. I was trying to develop an application for my teams performance management. Thanks again for your help! – muttalebm Dec 06 '12 at 13:05
1

Which version of PHP are you using?

There is apparently a bug in fsockopen ssl in some versions:

https://bugs.php.net/bug.php?id=54511

ckm
  • 1,326
  • 10
  • 15