Greetings,
I am working in myBB forum php and I have made some code adjustments where you can email an alternate registered user address instead of the default email address. This address happens to go to a console called the Nintendo Wii.
Therefore, in order for the Wii to accept the email to your console, it must be registered on your console as w1234567812345678@wii.com as an example.
I have setup where the emailto populates from my database and the script actually sends an email now but it gets bounced/blocked because its not FROM a valid wii.com address. Here is my code. Any help in understanding how the fromemail works and what I can do to get it to default to the logged in user's wiimail address would be great.
I know SQL more than anything and can write the sql statement in php to fetch the user's address for the FROM and then send the email to the user they are clicking on.
// <----- Begin WiiXchange Mod ----->
elseif($mybb->input['action'] == "wiimailuser")
{
$plugins->run_hooks("member_wiimailuser_start");
if($mybb->usergroup['cansendemail'] == "no")
{
error_no_permission();
}
if($mybb->input['uid'])
{
$query = $db->simple_select(TABLE_PREFIX."wiixchange", "wiimail, hidewiimail", "uid='".intval($mybb->input['uid'])."'");
$emailto = $db->fetch_array($query);
if(!$emailto['wiimail'])
{
error($lang->error_invalidpmrecipient);
}
if($emailto['hidewiimail'] != "no")
{
error($lang->error_hideemail);
}
}
if($mybb->user['uid'] == 0)
{
eval("\$guestfields = \"".$templates->get("member_wiimailuser_guest")."\";");
}
$plugins->run_hooks("member_wiimailuser_end");
eval("\$emailuser = \"".$templates->get("member_wiimailuser")."\";");
output_page($emailuser);
}
// <----- End WiiXchange Mod ----->
// <----- Begin WiiXchange Mod ----->
elseif($mybb->input['action'] == "do_wiimailuser" && $mybb->request_method == "post")
{
$plugins->run_hooks("member_do_wiimailuser_start");
if($mybb->usergroup['cansendemail'] == "no")
{
error_no_permission();
}
$query = $db->simple_select(TABLE_PREFIX."wiixchange", "uid, wiimail, wii_email, hidewiimail", "wiimail='".$db->escape_string($mybb->input['touser'])."'");
$emailto = $db->fetch_array($query);
if(!$emailto['wiimail'])
{
error($lang->error_invalidpmrecipient);
}
if($emailto['hidewiimail'] != "no")
{
error($lang->error_hideemail);
}
if(!$mybb->input['subject'] || !$mybb->input['message'])
{
error($lang->error_incompletefields);
}
if($mybb->user['uid'] == 0)
{
if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $mybb->input['fromemail']))
{
error($lang->error_invalidemail);
}
if(!$mybb->input['fromemail'])
{
error($lang->error_incompletefields);
}
$from = $mybb->input['fromemail'];
}
else
{
$from = $mybb->user['fromemail'];
}
my_mail($emailto['wii_email'], $parser->parse_badwords($mybb->input['subject']), $parser->parse_badwords($mybb->input['message']), $from);
$plugins->run_hooks("member_do_wiimailuser_end");
redirect("member.php?action=profile&uid=$emailto[uid]", $lang->redirect_emailsent);
}
// <----- End WiiXchange Mod ----->