I would like to make the mail_from configurable for resetting passwords.
Currently it is composed from the fixed “system” username and the URL of the server.
$this->db->update('ip_users', $db_array);
// Send the email with reset link
$this->load->helper('mailer');
// Preprare some variables for the email
$email_resetlink = site_url('sessions/passwordreset/' . $token);
$email_message = $this->load->view('emails/passwordreset', array(
'resetlink' => $email_resetlink
), true);
$email_from = 'system@' . preg_replace("/^[\w]{2,6}:\/\/([\w\d\.\-]+).*$/", "$1", base_url());
// Mail the invoice with the pre-configured mailer if possible
if (mailer_configured()) {
$this->load->helper('mailer/phpmailer');
if (!phpmail_send($email_from, $email, trans('password_reset'), $email_message)) {
$email_failed = true;
}
This can lead to problems if a user accesses the system from some wired IP address.
I suggest to add the “mail from” to the email configuration.
In the config settings like
</select>
</div>
<div id="div-smtp-settings">
<hr>
<div class="form-group">
<label for="settings[smtp_server_address]">
<?php _trans('smtp_server_address'); ?>
</label>
<input type="text" name="settings[smtp_server_address]" id="settings[smtp_server_address]"
class="form-control"
value="<?php echo get_setting('smtp_server_address', '', true); ?>">
</div>
<div class="form-group">
<label for="settings[smtp_authentication]">
<?php _trans('smtp_requires_authentication'); ?>
</label>
<select name="settings[smtp_authentication]" id="settings[smtp_authentication]"
class="form-control simple-select">
we can add:
<label for="settings[smtp_mail_from]">
<?php _trans('smtp_mail_from'); ?>
</label>
<input type="text" name="settings[smtp_mail_from]" id="settings[smtp_mail_from]"
class="form-control"
value="<?php echo get_setting('smtp_mail_from', '', true); ?>">
and save the mail_from to the database.
In the Sessions.php we could fallback to the system@
but otherwise read the mail_from from the database or we could directly wrap it in application/modules/mailer/helpers/phpmailer_helper.php
.
@nmay1990 Thanks, so I have something to refer my pull request to
Kovah
February 8, 2018, 2:40pm
5