Page 1 of 1

Feeling pretty stupid...

Posted: Mon Feb 25, 2008 4:20 pm
by LeapFrog
Hi Chris...

OK, I'm a new Swift Mailer user, having come this way after discovering that NMS Formmail won't let you send more than one outbound message per invocation.

I love the package; easy to install, and the smoke testing went great.

My hosting provider's server requires plain text SMTP authentication. Is there a recommended location for the connection code - for example, mine looks like this:

class StdConfig
{
var $CONNECTION_TYPE = "smtp";
var $SMTP_HOST = "smtp.host";
var $SMTP_PORT = 25;
var $SMTP_ENCRYPTION = false;
var $SMTP_USER = "username";
var $SMTP_PASS = "password";
var $SENDMAIL_PATH = "/usr/sbin/sendmail -bs";
};

$GLOBALS["CONF"] = new StdConfig();

At the moment I have this in the mainline code section of my .php form processor, but it seems to me it should go somewhere more secure.

What do you recommend?

Re: Feeling pretty stupid...

Posted: Tue Feb 26, 2008 9:43 am
by LeapFrog
OK, I THINK I solved part of the problem myself but moving this code to php.ini

register_globals = on
track_errors = yes
include_path = .:/usr/local/lib/php:/mylib/path


Now, what I still do not know is where to put the SMTP Auth information (for example)

class SMTPConfiguration
{
var $SMTP_HOST = "host.domain";/
var $SMTP_PORT = 25;
var $SMTP_ENCRYPTION = false;
var $SMTP_USER = "username";
var $SMTP_PASS = "password";
var $SENDMAIL_PATH = "/usr/sbin/sendmail -bs";
}
$GLOBALS["CONF"] = new SMTPConfiguration();

I tried putting the Authorization info in the executable script (which is a bad idea in any case because of security, right?) Anyway, the script works fine for a while (maybe 20 minutes) while I send six or so batch messages containing about 12 receipients. Then I start getting 'no authentication' errors like this one, which makes it appear that SMTP Auth isn't working:

++ Log level changed to 4 ++ Trying to connect... ++ Trying to connect to SMTP server at 'baywaytaskforce.org:25 << 220-maro.hmdnsgroup.com ESMTP Exim 4.68 #1 Tue, 26 Feb 2008 09:56:54 -0500 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. >> EHLO [63.247.139.39] << 250-maro.hmdnsgroup.com Hello [63.247.139.39] [63.247.139.39] 250-SIZE 52428800 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP ++ SMTP extension 'SIZE' reported with attributes [52428800]. ++ SMTP extension 'PIPELINING' reported with attributes []. ++ SMTP extension 'AUTH' reported with attributes [PLAIN, LOGIN]. ++ SMTP extension 'STARTTLS' reported with attributes []. ++ SMTP extension 'HELP' reported with attributes []. >> MAIL FROM: << 250 OK >> RCPT TO: << 550-([63.247.139.39]) [63.247.139.39] is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client. !! Expected response code(s) [250] but got response [550-([63.247.139.39]) [63.247.139.39] is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client.] !! Recipient 'ube.here@gmail.com' rejected by connection. >> RSET << 250 Reset OK >> MAIL FROM: << 250 OK >> RCPT TO: << 550-([63.247.139.39]) [63.247.139.39] is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client. !! Expected response code(s) [250] but got response [550-([63.247.139.39]) [63.247.139.39] is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client.] !! Recipient 'no.uce.here@gmail.com' rejected by connection. >> RSET << 250 Reset OK >> QUIT << 221 maro.hmdnsgroup.com closing connection ++ Closing down SMTP connection

Running a modified version of /tests/smokes/runTestOfBasicSend.php which invokes the Batch method works fine.

I admit to being new to php and OOP (too many years in the mainframe world) so maybe I am doing something so obviously wrong....that I just can't see it.

[edit]
I found the problem... needed these 4 lines of code in my .php script.
$smtp =& new Swift_Connection_SMTP("smtp.server", 25);
$smtp->setUsername("username");
$smtp->setpassword("password");
$swift =& new Swift($smtp);

Then of course I secured my script with .htaccess and permissions.

All is well that ends well.
[/edit]
Thanks.

Re: Feeling pretty stupid...

Posted: Wed Feb 27, 2008 6:04 am
by Chris Corbyn
It appears the authentication for that SMTP server is done using Pop Before SMTP (I hate that with a passion :P.... just kidding, but it is a non-standard nuisance).

Have a look in the docs authentication section, right down at the bottom of the page:

http://www.swiftmailer.org/wikidocs/v3/smtpauth

EDIT | Ah, so it also supports PLAIN and LOGIN authentication... Missed that bit... tis all good! :D