6

Please help me fix problem on Mac OS, when I type on my windows, It works. I try on my mac, it shows "could not open socket". Everybody could help me.

public function indexAction(){
    $mail = new Mail\Message;
                $mail->setFrom('paradise.losebaby@gmail.com','Flyoverfly Training');
                $mail->addTo('thanhbvh@yahoo.com.vn','maithanh');
                $mail->setSubject('Xác nhận việc phục hồi mật khẩu');
                $mail->setBody('maithanh');

                $transport = new SmtpTransport;
                $option = new SmtpOptions(array(
                    'name' => 'smtp.gmail.com',
                    'host' => 'smtp.gmail.com',
                    'port' => 465,
                    'connection_class' => 'login',
                    'connection_config' => array(
                        'username' => 'myemail@gmail.com',
                        'password' => 'mypass',
                        'ssl' => 'ssl'
                    )
                ));
                $transport->setOptions($option);
                $transport->send($mail);
    return new ViewModel;
}
ThanhAkira
  • 91
  • 1
  • 1
  • 3

1 Answers1

7

May be a firewall issue. However I'm pretty sure php-openssl doesn't installed/enabled on your OS. Under the hood Zend will call stream_socket_client() in order to connect to remote server. As sending email through gmail requires security layer (SSL/TLS), stream_socket_client() will require open ssl support (ssl://). So you must have ssl support on OS, check:


enter image description here Or getting the list of supported socket transports:

enter image description here

And here goes some useful links:

Community
  • 1
  • 1
felipsmartins
  • 13,269
  • 4
  • 48
  • 56