Sfift Mailer strange error

Hello,

on my local site I can send mail without problem for user login confermation, using user amnah module ( https://github.com/amnah/yii2-user ).

On the real site I can’t. Same configuration. Any idea?




Swift_TransportException

Connection could not be established with host smtp.gmail.com [Connection refused #111]


	1. in /home/maldistrjr/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php at line 265

	256257258259260261262263264265266267268269270271272273274


        	if (!empty($this->_params['timeout'])) {

            	$timeout = $this->_params['timeout'];

        	}

        	$options = array();

        	if (!empty($this->_params['sourceIp'])) {

            	$options['socket']['bindto'] = $this->_params['sourceIp'].':0';

        	}

        	$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));

        	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);

        	}


	2. in /home/maldistrjr/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php – Swift_Transport_StreamBuffer::_establishSocketConnection() at line 62

	56575859606162636465666768


        	switch ($params['type']) {

            	case self::TYPE_PROCESS:

                	$this->_establishProcessConnection();

                	break;

            	case self::TYPE_SOCKET:

            	default:

                	$this->_establishSocketConnection();

                	break;

        	}

    	}

 	

    	/**

 		* Set an individual param on the buffer (e.g. switching to SSL).


	3. in /home/maldistrjr/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php – Swift_Transport_StreamBuffer::initialize(['protocol' => 'tcp', 'host' => 'smtp.gmail.com', 'port' => 587, 'timeout' => 30, ...]) 

I had this same error last week when loading a site. Who is your host and are you using cpanel?

ovh.net, but I don’t administer directly this site and don’t have directly access to cpanel or anything else. It was assigned to me only a ftp account. But it is probably that it may be a provider restriction, maybe the firewall block sending smtp directly from Php or some missing php.ini option. Go to know. I must ask to provider.

But why you asking about cpanel? Every provider has your own, but is always interesting, maybe you find there some option for sending mail directly from site?

Solved. It was a trivial smtp port problem. My provider changed it, but without telling it to anyone. :slight_smile:

glad you got is solved