File: alert_functions.php

package info (click to toggle)
squirrelmail-logger 2.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 180 kB
  • ctags: 207
  • sloc: php: 811; sh: 136; makefile: 40
file content (102 lines) | stat: -rw-r--r-- 3,584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php

/**
  * SquirrelMail Squirrel Logger Plugin
  * Copyright (c) 2001-2008 Ron Chinn, Pat Winn, Paul Lesniewski
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * @package plugins
  * @subpackage squirrel_logger
  *
  */


/**
  * Sends email alerts
  *
  * Currently, only text messages are supported; no multipart HTML
  * or attachments allowed.
  *
  * @param $message string Text of message to be sent
  * @param $subject string Short text for inclusion in email subject line
  * @param $send_to string Comma-separated list of destination TO: addresses
  * @param $send_to_cc string Comma-separated list of destination CC: addresses
  * @param $send_to_bcc string Comma-separated list of destination BCC: addresses
  *
  */
function sl_send_alert($message, $subject, $send_to, $send_to_cc, $send_to_bcc)
{

   global $username, $domain, $sl_useSendmail, $sl_smtpServerAddress,
          $sl_smtpPort, $sl_sendmail_path, $sl_sendmail_args,
          $sl_pop_before_smtp, $sl_encode_header_key,
          $sl_smtp_auth_mech, $sl_smtp_sitewide_user,
          $sl_smtp_sitewide_pass, $useSendmail, $smtpServerAddress,
          $smtpPort, $sendmail_path, $sendmail_args, $pop_before_smtp,
          $encode_header_key, $smtp_auth_mech, $smtp_sitewide_user,
          $smtp_sitewide_pass;


   include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
   sl_get_config();


   // override any SMTP/Sendmail settings...
   //
   $orig_useSendmail = $useSendmail;
   if (!is_null($sl_useSendmail))
      $useSendmail = $sl_useSendmail;
   $orig_smtpServerAddress = $smtpServerAddress;
   if (!is_null($sl_smtpServerAddress))
      $smtpServerAddress = $sl_smtpServerAddress;
   $orig_smtpPort = $smtpPort;
   if (!is_null($sl_smtpPort))
      $smtpPort = $sl_smtpPort;
   $orig_sendmail_path = $sendmail_path;
   if (!is_null($sl_sendmail_path))
      $sendmail_path = $sl_sendmail_path;
   $orig_sendmail_args = $sendmail_args;
   if (!is_null($sl_sendmail_args))
      $sendmail_args = $sl_sendmail_args;
   $orig_pop_before_smtp = $pop_before_smtp;
   if (!is_null($sl_pop_before_smtp))
      $pop_before_smtp = $sl_pop_before_smtp;
   $orig_encode_header_key = $encode_header_key;
   if (!is_null($sl_encode_header_key))
      $encode_header_key = $sl_encode_header_key;
   $orig_smtp_auth_mech = $smtp_auth_mech;
   if (!is_null($sl_smtp_auth_mech))
      $smtp_auth_mech = $sl_smtp_auth_mech;
   $orig_smtp_sitewide_user = $smtp_sitewide_user;
   if (!is_null($sl_smtp_sitewide_user))
      $smtp_sitewide_user = $sl_smtp_sitewide_user;
   $orig_smtp_sitewide_pass = $smtp_sitewide_pass;
   if (!is_null($sl_smtp_sitewide_pass))
      $smtp_sitewide_pass = $sl_smtp_sitewide_pass;


   // function found in SM core 1.5.2+ and Compatibility plugin 2.0.11+
   // (suppress include error, since file is only needed for 1.5.2+,
   // otherwise Compatibility has us covered)
   //
   @include_once(SM_PATH . 'functions/compose.php');
   $success = sq_send_mail($send_to, $subject, $message, 'noreply@' . $domain, $send_to_cc, $send_to_bcc);


   // return SMTP/Sendmail settings to what they were
   //
   $useSendmail = $orig_useSendmail;
   $smtpServerAddress = $orig_smtpServerAddress;
   $smtpPort = $orig_smtpPort;
   $sendmail_path = $orig_sendmail_path;
   $sendmail_args = $orig_sendmail_args;
   $pop_before_smtp = $orig_pop_before_smtp;
   $encode_header_key = $orig_encode_header_key;
   $smtp_auth_mech = $orig_smtp_auth_mech;
   $smtp_sitewide_user = $orig_smtp_sitewide_user;
   $smtp_sitewide_pass = $orig_smtp_sitewide_pass;

}