Hey, got my hands on this implementation of Koops MailingList, thanks to sottwell!
Now, my client is using an external SMTP service which needs authentication. It seems people are having the same problem that I have had, so I’ll share my hacks here.
Using SMTP server
I’ve searched through every source files and it doesn’t seems like the config var $mailserver is used anywhere. At least, it doesn’t appear anywhere else than in the config.php file. So, anyways, I did a quick hack by modifying 2 lines in both functions.php and admin.php.
First in functions.php, around line 71, I modified the source code to look like this:
if(($phpversion > 4)&&($phpversion < 5)){
require('Swift/Swift.php');
require('Swift/Swift/Swift_Sendmail_Connection.php');
require('Swift/Swift/Swift_SMTP_Connection.php' );
}elseif($phpversion >=5){
require('Swift5/Swift.php');
require('Swift5/Swift/Swift_Sendmail_Connection.php');
require('Swift5/Swift/Swift_SMTP_Connection.php' );
}
$mail = new Swift(new Swift_SMTP_Connection('mail.yourhost.com'));
$mail->authenticate( 'smtp_username', 'smtp_password' );
So, as you can see, I added two lines to include the SMTP connection class and then modified the creation of the Swift object to use the SMTP class instead. You can also specify the server port and if you need SSL (second and third, optional) like this:
$mail = new Swift(new Swift_SMTP_Connection('foo.bar.com', 9976, SWIFT_SSL);Other possible values for the third parameters are: SWIFT_OPEN (false/default), SWIFT_SSL (normal SSL), SWIFT_TLS (TLS/SSL).
The $mail->authenticate() call is only required if your SMTP server requires authentication. Username first and password second.
Now, same thing goes for the admin.php file, around line 55, here’s the changes I made:
case "2":
// automatically send newsletter
require('Swift/Swift.php');
require('Swift/plugins/Swift_Anti_Flood_Plugin.php');
require('Swift/Swift/Swift_Sendmail_Connection.php');
require('Swift/Swift/Swift_SMTP_Connection.php');
$sql = "SELECT id, email FROM ".$prefix."subscribers";
$result = $modx->db->query($sql);
$recipients = array();
while($newArray = $modx->db->getRow($result)){
array_push($recipients, $newArray['email']);
}
$mail = new Swift(new Swift_Connection_SMTP('smtp.yourserver.com'));
$mail->authenticate( 'username', 'password' );
$text = str_replace('/UserFiles','http://'.$_SERVER['HTTP_HOST'].'/UserFiles', $_POST['FCKeditor1']);
Again, this is a dirty hack. Those parameters should probably go in the config.php file, but I hope this helps someone.
More coming up.