Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

SMTP Support #310

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenVBX/config/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
See: http://codeigniter.com/user_guide/libraries/email.html
| -------------------------------------------------------------------
*/
$config['useragent'] = 'CodeIgniter'; //The "user agent".
$config['useragent'] = 'OpenVBX-'.OpenVBX::version(); //The "user agent".
$config['protocol'] = 'mail'; //mail, sendmail, or smtp The mail sending protocol.
$config['mailpath'] = '/usr/sbin/sendmail'; //The server path to Sendmail.

Expand Down
18 changes: 11 additions & 7 deletions OpenVBX/helpers/mail_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ function openvbx_mail($recipient, $subject, $template, $maildata = array())
$ci = &get_instance();

$from_email = $ci->settings->get('from_email', $ci->tenant->id);

if(empty($from_email))
{
$domain = $ci->config->item('server_name');
$from_email = "$from <do-not-reply@$domain>";
}

$headers = 'From: '.$from_email."\r\n";
$headers .= 'Reply-To: '.$from_email."\r\n";
$headers .= 'Return-Path: '.$from_email."\r\n";
$headers .= 'User-Agent: OpenVBX-'.OpenVBX::version();


$message = $ci->load->view('emails/'.$template, $maildata, true);

$ci->load->library('email');
$ci->email->from($from_email);
$ci->email->reply_to($from_email);
$ci->email->to($recipient);
$ci->email->subject('[OpenVBX] '.$subject);
$ci->email->message($message);

log_message('debug', 'MAILING -- to: '.$recipient.' -- body: '.$message);
return mail($recipient, '[OpenVBX] '.$subject, $message, $headers);

return $ci->email->send();
}
2 changes: 1 addition & 1 deletion system/libraries/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function _assign_libraries($use_reference = TRUE)
if ($use_reference == TRUE)
{
$this->$key = NULL; // Needed to prevent reference errors with some configurations
$this->$key =& $CI->$key;
$this->$key = $CI->$key;
}
}
}
Expand Down