summaryrefslogtreecommitdiff
path: root/program/steps/mail/sendmail.inc
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2005-09-30 22:04:50 +0000
committerthomascube <thomas@roundcube.net>2005-09-30 22:04:50 +0000
commit968bdc7c90f718560b84eb3b7e8e1d02cf4270f3 (patch)
treea97784b62efac5215dc1cd71ea6b9a53aa753d8e /program/steps/mail/sendmail.inc
parent15fee7b8dd9991c798e6b3eeb9f98cd34e8153fc (diff)
Improved SMTP script for sending mails. Now using the PEAR::Net_SMTP class
Diffstat (limited to 'program/steps/mail/sendmail.inc')
-rw-r--r--program/steps/mail/sendmail.inc37
1 files changed, 18 insertions, 19 deletions
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index e33593139..2172accc8 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -21,7 +21,8 @@
*/
-require_once('lib/smtp.inc');
+//require_once('lib/smtp.inc');
+require_once('include/rcube_smtp.inc');
require_once('Mail/mime.php');
@@ -155,30 +156,28 @@ $msg_subject = $headers['Subject'];
// send thru SMTP server using cusotm SMTP library
if ($CONFIG['smtp_server'])
{
- // connect to SMTP server
- $smtp_conn = smtp_connect($CONFIG['smtp_server'], '25', $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
-
- if ($smtp_conn)
- {
- // generate list of recipients
- $recipients = $mailto.', '.$headers['Cc'].', '.$headers['Bcc'];
- $a_recipients = smtp_expand($recipients);
-
- // generate message headers
- $header_str = $MAIL_MIME->txtHeaders($headers);
-
- // send message
- $sent = smtp_mail($smtp_conn, $from, $a_recipients, $header_str."\r\n".$msg_body, FALSE);
- }
-
+ // generate list of recipients
+ $a_recipients = array($mailto);
+
+ if (strlen($headers['Cc']))
+ $a_recipients[] = $headers['Cc'];
+ if (strlen($headers['Bcc']))
+ $a_recipients[] = $headers['Bcc'];
+
+ // generate message headers
+ $header_str = $MAIL_MIME->txtHeaders($headers);
+
+ // send message
+ $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body);
+
// log error
- if (!$smtp_conn || !$sent)
+ if (!$sent)
{
raise_error(array('code' => 800,
'type' => 'smtp',
'line' => __LINE__,
'file' => __FILE__,
- 'message' => "Connection failed: $smtp_error"), TRUE, FALSE);
+ 'message' => "SMTP error: $SMTP_ERROR"), TRUE, FALSE);
}
}