Added the capability to use a debug email address for receiving all the

sent emails
This commit is contained in:
bison-paolo
2016-10-12 16:53:45 +02:00
parent ccb9daffaa
commit 4ace90adc7
3 changed files with 44 additions and 19 deletions
+18 -17
View File
@@ -1,30 +1,31 @@
<?php
// Define constants
define("EMAIL_CONFIG_INDEX", "mail");
define('EMAIL_CONFIG_INDEX', 'mail');
// Define configuration parameters
$config["email_number_to_sent"] = 1000; // Number of emails to sent each time sendAll is called
$config["email_number_per_time_range"] = 1; // Number of emails to sent before pause
$config["email_time_range"] = 1; // Length of the pause in seconds
$config["email_from_system"] = "no-reply@technikum-wien.at";
$config['email_number_to_sent'] = 1000; // Number of emails to sent each time sendAll is called
$config['email_number_per_time_range'] = 1; // Number of emails to sent before pause
$config['email_time_range'] = 1; // Length of the pause in seconds
$config['email_from_system'] = 'no-reply@technikum-wien.at';
// Smtp: if the CI email library has to connect to a smtp server
// Mail: if the system is setup to send emails with the standard php mail function
// Sendmail: if the system is setup to send email via Sendmail (or similar)
$config["protocol"] = ""; // mail, sendmail, or smtp
$config['protocol'] = ''; // mail, sendmail, or smtp
// If protocol is set to sendmail
$config["mailpath"] = ""; // SThe server path to Sendmail (or similar)
$config['mailpath'] = ''; // SThe server path to Sendmail (or similar)
// If protocol is set to smtp
$config["smtp_host"] = "localhost"; // SMTP Server Address
$config["smtp_port"] = 25;
$config["smtp_timeout"] = 5; // in seconds
$config["smtp_keepalive"] = false; // Enable persistent SMTP connections
$config["smtp_user"] = "";
$config["smtp_pass"] = "";
$config["wordwrap"] = true; // {unwrap}http://example.com/a_long_link_that_should_not_be_wrapped.html{/unwrap}
$config["wrapchars"] = 76; // Character count to wrap at.
$config["mailtype"] = "html"; // html or text
$config["priority"] = 3; // Email Priority. 1 = highest. 5 = lowest. 3 = normal
$config['smtp_host'] = 'localhost'; // SMTP Server Address
$config['smtp_port'] = 25;
$config['smtp_timeout'] = 5; // in seconds
$config['smtp_keepalive'] = false; // Enable persistent SMTP connections
$config['smtp_user'] = '';
$config['smtp_pass'] = '';
$config['wordwrap'] = true; // {unwrap}http://example.com/a_long_link_that_should_not_be_wrapped.html{/unwrap}
$config['wrapchars'] = 76; // Character count to wrap at.
$config['mailtype'] = 'html'; // html or text
$config['priority'] = 3; // Email Priority. 1 = highest. 5 = lowest. 3 = normal
$config['validate'] = false; // If true then the email address will be validated
+1 -1
View File
@@ -3,7 +3,7 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
$config['msg_delivery'] = true;
$config['send_immediately'] = false; // If the message should be sent immediately
$config['send_immediately'] = true; // If the message should be sent immediately
$config['system_person_id'] = 1; // Dummy sender, used for sending messages from the system
$config['redirect_view_message_url'] = 'index.ci.php/Redirect/redirectByToken/'; //
$config['message_html_view_url'] = 'index.ci.php/ViewMessage/toHTML/';
+25 -1
View File
@@ -54,7 +54,16 @@ class MailLib
}
$this->ci->email->from($from, $alias);
$this->ci->email->to($to);
// Check if the email address of the debug recipient is a valid one
$recipient = $to;
if ($this->validateEmailAddress(MAIL_DEBUG))
{
// if is it valid use it!!!
$recipient = MAIL_DEBUG;
}
$this->ci->email->to($recipient);
if (!is_null($cc)) $this->ci->email->cc($cc);
if (!is_null($bcc)) $this->ci->email->bcc($bcc);
$this->ci->email->subject($subject);
@@ -115,6 +124,21 @@ class MailLib
return $cfg;
}
/**
* Validates an email address
*/
public function validateEmailAddress($emailAddress)
{
$valid = false;
if (!empty($emailAddress))
{
$valid = filter_var($emailAddress, FILTER_VALIDATE_EMAIL);
}
return $valid;
}
/**
* Checks if it has to wait until the sending of the next
*/