SwiftMailer instead of mail()
Posted: Mon Sep 18, 2006 9:36 am
Hi,
Script I made has two modes for mailing. First (default one) will use settings from php.ini to send emails through SwiftMailer. Second one requires user to provide a valid SMTP server. Idea was to make things work out of the box for people who have properly configured mailing in PHP but at the same time to provide more power to people who need it. I've skipped mail() because script usualy needs to send multiple emails at once...
SMTP is working wihout any problems, but code I wrote that reads config from php.ini doesn't (script tries to send email and hangs until execution time is reached). Code:
What am I doing wrong here? Should this work?
Thanks!
Script I made has two modes for mailing. First (default one) will use settings from php.ini to send emails through SwiftMailer. Second one requires user to provide a valid SMTP server. Idea was to make things work out of the box for people who have properly configured mailing in PHP but at the same time to provide more power to people who need it. I've skipped mail() because script usualy needs to send multiple emails at once...
SMTP is working wihout any problems, but code I wrote that reads config from php.ini doesn't (script tries to send email and hangs until execution time is reached). Code:
Code: Select all
$sendmail_path = ini_get('sendmail_path');
if($sendmail_path) {
return new Swift(new Swift_Sendmail_Connection($sendmail_path)); // use sendmail
} else {
return new Swift(new Swift_SMTP_Connection(ini_get('SMTP'), ini_get('smtp_port'))); // use SMTP
} // ifThanks!