Ok, here's what I've been able to find:
Line 2706 in member.php seems to indicate that this is for user to user emails.
if($mybb->input['action'] == "do_emailuser" && $mybb->request_method == "post")
In member.php, lines 2799 - 2852, seems to build the mail parameters.
if($mybb->user['uid'])
{
$mybb->input['fromemail'] = $mybb->user['email'];
$mybb->input['fromname'] = $mybb->user['username'];
}
if(!validate_email_format($mybb->input['fromemail']))
{
$errors[] = $lang->error_invalidfromemail;
}
if(empty($mybb->input['fromname']))
{
$errors[] = $lang->error_noname;
}
if(empty($mybb->input['subject']))
{
$errors[] = $lang->error_no_email_subject;
}
if(empty($mybb->input['message']))
{
$errors[] = $lang->error_no_email_message;
}
if($mybb->settings['captchaimage'] && $mybb->user['uid'] == 0)
{
require_once MYBB_ROOT.'inc/class_captcha.php';
$captcha = new captcha;
if($captcha->validate_captcha() == false)
{
// CAPTCHA validation failed
foreach($captcha->get_errors() as $error)
{
$errors[] = $error;
}
}
}
if(count($errors) == 0)
{
if($mybb->settings['mail_handler'] == 'smtp')
{
$from = $mybb->input['fromemail'];
}
else
{
$from = "{$mybb->input['fromname']} <{$mybb->input['fromemail']}>";
}
$message = $lang->sprintf($lang->email_emailuser, $to_user['username'], $mybb->input['fromname'], $mybb->settings['bbname'], $mybb->settings['bburl'], $mybb->get_input('message'));
my_mail($to_user['email'], $mybb->get_input('subject'), $message, $from, "", "", false, "text", "", $mybb->input['fromemail']);
This block calls the function my_mail, which is in functions.php:
function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")
{
global $mybb;
static $mail;
// Does our object not exist? Create it
if(!is_object($mail))
{
require_once MYBB_ROOT."inc/class_mailhandler.php";
if($mybb->settings['mail_handler'] == 'smtp')
{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";
$mail = new SmtpMail();
}
else
{
require_once MYBB_ROOT."inc/mailhandlers/php.php";
$mail = new PhpMail();
}
}
// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')
{
if($keep_alive == true)
{
$mail->keep_alive = true;
}
}
// Using PHP based mail()
else
{
if($mybb->settings['mail_parameters'] != '')
{
$mail->additional_parameters = $mybb->settings['mail_parameters'];
}
}
// Build and send
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
return $mail->send();
If I look back at the my_mail function call from member.php:
my_mail($to_user['email'], $mybb->get_input('subject'), $message, $from, "", "", false, "text", "", $mybb->input['fromemail']);
The return email is being sent as the from email address from the $mybb->input['fromemail'] variable.
So what if I take this block right above it:
else
{
$from = "{$mybb->input['fromname']} <{$mybb->input['fromemail']}>";
}
And hardcode the variable $from variable to my web host email address?
Would that be a good / safe way to make the user to user emails work for all emails?