I was having problem too.
I solved it by setting the encryption setting to tls
.
With Google I didn't have any problem using this port: 'port' => 587,
According to arclab google's smpt setup:
smtp.gmail.com --- SSL --- 465
smtp.gmail.com --- StartTLS --- 587
Then double check if your login credentials are correct.
Also i found out that sometimes google/gmail blocks your account from sending mails if you're trying to send from a different location so your account needs to authorize this.
replace _establishSocketConnection with the modification func
private function _establishSocketConnection() { $host = $this->_params['host']; if (!empty($this->_params['protocol'])) { $host = $this->_params['protocol'].'://'.$host; } $timeout = 15; if (!empty($this->_params['timeout'])) { $timeout = $this->_params['timeout']; } $options = array();
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
if (!empty($this->_params['sourceIp'])) {
$options['socket']['bindto'] = $this->_params['sourceIp'].':0';
}
if (isset($this->_params['stream_context_options'])) {
$options = array_merge($options, $this->_params['stream_context_options']);
}
$streamContext = stream_context_create($options);
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host '.$this->_params['host'].
' ['.$errstr.' #'.$errno.']'
);
}
if (!empty($this->_params['blocking'])) {
stream_set_blocking($this->_stream, 1);
} else {
stream_set_blocking($this->_stream, 0);
}
stream_set_timeout($this->_stream, $timeout);
$this->_in = &$this->_stream;
$this->_out = &$this->_stream;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community