[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] SF.net SVN: squirrelmail: [12978]
From: pdontthink () users ! sourceforge ! net
Date: 2008-02-29 22:42:51
Message-ID: E1JVDwJ-0008RQ-Dm () sc8-pr-svn2 ! sourceforge ! net
[Download RAW message or body]
Revision: 12978
http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=12978&view=rev
Author: pdontthink
Date: 2008-02-29 14:42:51 -0800 (Fri, 29 Feb 2008)
Log Message:
-----------
Add sq_send_mail()
Modified Paths:
--------------
trunk/squirrelmail/functions/compose.php
Modified: trunk/squirrelmail/functions/compose.php
===================================================================
--- trunk/squirrelmail/functions/compose.php 2008-02-28 09:07:22 UTC (rev 12977)
+++ trunk/squirrelmail/functions/compose.php 2008-02-29 22:42:51 UTC (rev 12978)
@@ -59,3 +59,111 @@
}
+/**
+ * Send a simple mail message using SquirrelMail's API.
+ *
+ * Until SquirrelMail is sufficiently redesigned, this
+ * function is a stand-in for a simple mail delivery
+ * call. Currently, it only sends plaintext messages
+ * (unless the caller uses the $message parameter).
+ *
+ * @param string $to The destination recipient.
+ * @param string $subject The message subject.
+ * @param string $body The message body.
+ * @param string $from The sender.
+ * @param string $cc The destination carbon-copy recipient.
+ * (OPTIONAL; default no Cc:)
+ * @param string $bcc The destination blind carbon-copy recipient.
+ * (OPTIONAL; default no Bcc:)
+ * @param object $message If the caller wants to construct a more
+ * complicated message themselves and pass
+ * it here, this function will take care
+ * of the rest - handing it over to SMTP
+ * or Sendmail. If this parameter is non-
+ * empty, all other parameters are ignored.
+ * (OPTIONAL: default is empty)
+ *
+ * @return array A two-element array, the first element being a
+ * boolean value indicating if the message was successfully
+ * sent or not, and the second element being the message's
+ * assigned Message-ID, if available (only available as of
+ * SquirrelMail 1.4.14 and 1.5.2)
+ *
+ */
+function sq_send_mail($to, $subject, $body, $from, $cc='', $bcc='', $message='')
+{
+
+ if (empty($message))
+ {
+ $message = new Message();
+ $header = new Rfc822Header();
+
+ $message->setBody($body);
+ $content_type = new ContentType('text/plain');
+ global $special_encoding, $default_charset;
+ if ($special_encoding)
+ $rfc822_header->encoding = $special_encoding;
+ else
+ $rfc822_header->encoding = '8bit';
+ if ($default_charset)
+ $content_type->properties['charset']=$default_charset;
+ $header->content_type = $content_type;
+
+ $header->parseField('To', $to);
+ $header->parseField('Cc', $cc);
+ $header->parseField('Bcc', $bcc);
+ $header->parseField('From', $from);
+ $header->parseField('Subject', $subject);
+ $message->rfc822_header = $header;
+ }
+//sm_print_r($message);exit;
+
+
+ global $useSendmail;
+
+
+ // ripped from src/compose.php - based on both 1.5.2 and 1.4.14
+ //
+ if (!$useSendmail) {
+ require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
+ $deliver = new Deliver_SMTP();
+ global $smtpServerAddress, $smtpPort, $pop_before_smtp, $domain;
+
+ $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false;
+ $user = '';
+ $pass = '';
+ get_smtp_user($user, $pass);
+ $stream = $deliver->initStream($message,$domain,0,
+ $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
+ } else {
+ require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
+ global $sendmail_path, $sendmail_args;
+ // Check for outdated configuration
+ if (!isset($sendmail_args)) {
+ if ($sendmail_path=='/var/qmail/bin/qmail-inject') {
+ $sendmail_args = '';
+ } else {
+ $sendmail_args = '-i -t';
+ }
+ }
+ $deliver = new Deliver_SendMail(array('sendmail_args'=>$sendmail_args));
+ $stream = $deliver->initStream($message,$sendmail_path);
+ }
+
+
+ $success = false;
+ $message_id = '';
+ if ($stream) {
+ $deliver->mail($message, $stream);
+ if (!empty($message->rfc822_header->message_id)) {
+ $message_id = $message->rfc822_header->message_id;
+ }
+
+ $success = $deliver->finalizeStream($stream);
+ }
+
+ return array($success, $message_id);
+
+}
+
+
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-----
squirrelmail-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic