Permalink
Browse files

allow multiple recipients (Cc and Bcc) (requests #5707 and #5987)

git-svn-id: https://svn.php.net/repository/pear/packages/Mail_Queue/trunk@202405 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 84f87d9 commit dd6bf6ad18e2784cf82142381a9f541b2bf60848 @quipo quipo committed Dec 8, 2005
Showing with 75 additions and 29 deletions.
  1. +11 −4 Queue.php
  2. +23 −15 Queue/Body.php
  3. +32 −1 Queue/Container.php
  4. +2 −2 Queue/Container/db.php
  5. +2 −2 Queue/Container/mdb.php
  6. +2 −2 Queue/Container/mdb2.php
  7. +1 −2 docs/mdb_mail_queue_schema.xml
  8. +2 −1 package.xml
View
@@ -395,7 +395,7 @@ function get()
* @param integer $id_user Sender id
* @param string $ip Sender ip
* @param string $from Sender e-mail
- * @param string $to Reciepient e-mail
+ * @param string|array $to Reciepient(s) e-mail
* @param string $hdrs Mail headers (in RFC)
* @param string $body Mail body (in RFC)
* @return mixed ID of the record where this mail has been put
@@ -407,9 +407,16 @@ function put($from, $to, $hdrs, $body, $sec_to_send=0, $delete_after_send=true,
{
$ip = getenv('REMOTE_ADDR');
$time_to_send = date("Y-m-d G:i:s", time() + $sec_to_send);
- return $this->container->put( $time_to_send, $id_user,
- $ip, $from, $to, serialize($hdrs),
- serialize($body), $delete_after_send );
+ return $this->container->put(
+ $time_to_send,
+ $id_user,
+ $ip,
+ $from,
+ serialize($to),
+ serialize($hdrs),
+ serialize($body),
+ $delete_after_send
+ );
}
// }}}
View
@@ -14,6 +14,7 @@
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Radek Maciaszek <chief@php.net> |
+// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
// $Id$
@@ -139,7 +140,7 @@ class Mail_Queue_Body {
* @return void
*
* @access public
- **/
+ */
function Mail_Queue_Body($id, $create_time, $time_to_send, $sent_time, $id_user,
$ip, $sender, $recipient, $headers, $body,
$delete_after_send=true, $try_sent=0)
@@ -163,7 +164,7 @@ function Mail_Queue_Body($id, $create_time, $time_to_send, $sent_time, $id_user,
*
* @return integer Sender id
* @access public
- **/
+ */
function getId()
{
return $this->id;
@@ -176,7 +177,7 @@ function getId()
*
* @return string Mail create time
* @access public
- **/
+ */
function getCreateTime()
{
return $this->create_time;
@@ -189,7 +190,7 @@ function getCreateTime()
*
* @return string Time to send
* @access public
- **/
+ */
function getTimeToSend()
{
return $this->time_to_send;
@@ -202,7 +203,7 @@ function getTimeToSend()
*
* @return mixed String sent time or false if mail not was sent yet
* @access public
- **/
+ */
function getSentTime()
{
return empty($this->sent_time) ? false : $this->sent_time;
@@ -215,7 +216,7 @@ function getSentTime()
*
* @return integer Sender id
* @access public
- **/
+ */
function getIdUser()
{
return $this->id_user;
@@ -228,7 +229,7 @@ function getIdUser()
*
* @return string IP
* @access public
- **/
+ */
function getIp()
{
return stripslashes($this->ip);
@@ -241,7 +242,7 @@ function getIp()
*
* @return string E-mail
* @access public
- **/
+ */
function getSender()
{
return stripslashes($this->sender);
@@ -252,11 +253,18 @@ function getSender()
*
* Mail_Queue_Body::getRecipient()
*
- * @return string E-mail
+ * @return string|array E-mail(s)
* @access public
- **/
+ */
function getRecipient()
{
+ if (is_array($this->recipient)) {
+ $tmp_recipients = array();
+ foreach ($this->recipient as $key => $value) {
+ $tmp_recipients[$key] = stripslashes($value);
+ }
+ return $tmp_recipients;
+ }
return stripslashes($this->recipient);
}
@@ -267,7 +275,7 @@ function getRecipient()
*
* @return mixed array|string headers
* @access public
- **/
+ */
function getHeaders()
{
if (is_array($this->headers)) {
@@ -287,7 +295,7 @@ function getHeaders()
*
* @return string Body
* @access public
- **/
+ */
function getBody()
{
return stripslashes($this->body);
@@ -300,7 +308,7 @@ function getBody()
*
* @return integer How many times mail was sent
* @access public
- **/
+ */
function getTrySent()
{
return $this->try_sent;
@@ -313,7 +321,7 @@ function getTrySent()
*
* @return bool True if must be delete else false.
* @access public
- **/
+ */
function isDeleteAfterSend()
{
return $this->delete_after_send;
@@ -326,7 +334,7 @@ function isDeleteAfterSend()
*
* @return integer How many times mail was sent
* @access public
- **/
+ */
function _try()
{
return ++$this->try_sent;
View
@@ -92,7 +92,7 @@ class Mail_Queue_Container
*/
function get()
{
- if (Mail_Queue::isError($err = $this->preload())) {
+ if (PEAR::isError($err = $this->preload())) {
return $err;
}
if (empty($this->queue_data)) {
@@ -274,5 +274,36 @@ function preload()
}
// }}}
+ // {{{ _isSerialized()
+
+ /**
+ * Check if the string is a regular string or a serialized array
+ *
+ * @param string $string
+ * @return boolean
+ * @access protected
+ */
+ function _isSerialized($string)
+ {
+ if (!is_string($string) || strlen($string) < 4) {
+ return false;
+ }
+ // serialized integer?
+ if (preg_match('/^i:\d+;$/', $string)) {
+ return true;
+ }
+ // serialized float?
+ if (preg_match('/^d:\d(\.\d+)?;$/', $string)) {
+ return true;
+ }
+ // serialized string?
+ if (preg_match('/^s:\d+\:\"(.*)\";$/', $string)) {
+ return true;
+ }
+ //serialized array?
+ return preg_match('/^a:\d+\:\{(.*)\}$/', $string);
+ }
+
+ // }}}
}
?>
View
@@ -145,7 +145,7 @@ function _preload()
$row['id_user'],
$row['ip'],
$row['sender'],
- $row['recipient'],
+ $this->_isSerialized($row['recipient']) ? unserialize($row['recipient']) : $row['recipient'],
unserialize($row['headers']),
unserialize($row['body']),
$row['delete_after_send'],
@@ -313,7 +313,7 @@ function getMailById($id)
$row['id_user'],
$row['ip'],
$row['sender'],
- $row['recipient'],
+ $this->_isSerialized($row['recipient']) ? unserialize($row['recipient']) : $row['recipient'],
unserialize($row['headers']),
unserialize($row['body']),
$row['delete_after_send'],
View
@@ -253,7 +253,7 @@ function _preload()
* @return mixed ID of the record where this mail has been put
* or Mail_Queue_Error on error
* @access public
- **/
+ */
function put($time_to_send, $id_user, $ip, $sender,
$recipient, $headers, $body, $delete_after_send=true)
{
@@ -473,7 +473,7 @@ function getMailById($id)
$row['id_user'],
$row['ip'],
$row['sender'],
- $row['recipient'],
+ $this->_isSerialized($row['recipient']) ? unserialize($row['recipient']) : $row['recipient'],
unserialize($row['headers']),
unserialize($row['body']),
$row['delete_after_send'],
View
@@ -133,7 +133,7 @@ function _preload()
$row['id_user'],
$row['ip'],
$row['sender'],
- $row['recipient'],
+ $this->_isSerialized($row['recipient']) ? unserialize($row['recipient']) : $row['recipient'],
unserialize($row['headers']),
unserialize($row['body']),
$row['delete_after_send'],
@@ -292,7 +292,7 @@ function getMailById($id)
$row['id_user'],
$row['ip'],
$row['sender'],
- $row['recipient'],
+ $this->_isSerialized($row['recipient']) ? unserialize($row['recipient']) : $row['recipient'],
unserialize($row['headers']),
unserialize($row['body']),
$row['delete_after_send'],
@@ -62,8 +62,7 @@
<field>
<name>recipient</name>
- <type>text</type>
- <length>50</length>
+ <type>clob</type>
<default></default>
<notnull>1</notnull>
</field>
View
@@ -32,7 +32,7 @@ every few minutes) by crontab or in other way.
</maintainers>
<release>
<version>1.1.4</version>
- <date>2005-07-01</date>
+ <date>2005-12-08</date>
<state>stable</state>
<license>PHP</license>
<notes>
@@ -42,6 +42,7 @@ every few minutes) by crontab or in other way.
(related to bug #4028)
- removed any MySQL-specific functions from the SQL queries
in the DB container.
+- allow multiple recipients (Cc and Bcc) (requests #5707 and #5987)
</notes>
<filelist>
<dir name="/" baseinstalldir="Mail">

0 comments on commit dd6bf6a

Please sign in to comment.