Page 1 of 1

swiftmailer problem

Posted: Thu Aug 31, 2006 5:08 am
by rsmarsha
I've been trying to get swiftmailer working for a while. I went through the documentation for testing with auth smtp.

Code: Select all

require('swift/Swift.php');
require('swift/Swift/Connection/SMTP.php');

$mailer = new Swift(new Swift_Connection_SMTP('my smtp server', SWIFT_SECURE_PORT, SWIFT_TLS));

//If anything goes wrong you can see what happened in the logs
if ($mailer->isConnected()) //Optional
{
	//You can call authenticate() anywhere before calling send()
	if ($mailer->authenticate('username', 'password'))
	{
		//Sends a simple email
		$mailer->send(
			'"Joe Bloggs" <mail@iwanttosendto.com>',
			'"Your name" <you@yourdomain.com>',
			'Some Subject',
			"Hello Joe it's only me!"
		);
	}
	else echo "Didn't authenticate to server";
	
	//Closes cleanly... works without this but it's not as polite.
	$mailer->close();
}
else echo "The mailer failed to connect. Errors: <pre>".print_r($mailer->errors, 1)."</pre><br />
	Log: <pre>".print_r($mailer->transactions, 1)."</pre>";

print_r($mailer->transactions);
I get the can't connect error. I tried telnet entering "o", enter, smtpserveraddress 25.

This connected me to my smtp server, so i assume thats ok. Not sure why it's not connecting.

Posted: Thu Aug 31, 2006 6:13 am
by Chris Corbyn
If you telnetted I guess your server doesn't use TLS so take out the TLS part, and also the SECURE_PORT bit (that's not port 25).

Posted: Thu Aug 31, 2006 7:28 am
by rsmarsha
Still getting

Code: Select all

The mailer failed to connect. Errors: 
Array
(
    [0] => Array
        (
            [num] => 0
            [time] => 0.76055600 1157027231
            [message] => Connection to the given MTA failed. The Connection Interface said: Connection refused
        )

)


Log: 
Array
(
)

Array ( )

Posted: Thu Aug 31, 2006 7:52 am
by Chris Corbyn
rsmarsha wrote:Connection refused
And there you have it :) Something is blocking access to the server. Shared host? ;)

Posted: Fri Sep 01, 2006 3:55 am
by rsmarsha
Yeah it's 1and1, work host. Any idea how i get round this? Or do i just have to use php's mail fuction?

Posted: Fri Sep 01, 2006 7:33 am
by Chris Corbyn
rsmarsha wrote:Yeah it's 1and1, work host. Any idea how i get round this? Or do i just have to use php's mail fuction?
1and1 block outgoing access on most ports for their basic accounts. You need a premium account with them if you want more... you're probably best contacting them yourself. This has been mentioned before about 1and1.

EDIT | Version 2.1.13 includes a connection called "NativeMail" which uses mail() to do the actual sending.