Not tested, but you could try in main.inc.php
$temparr = array(0=>'',1='localhost');
if(isset($_POST['_user']))
$temparr = explode('@',get_input_value('_user', RCUBE_INPUT_POST));
else if(isset($_SESSION['username']))
$temparr = explode('@', $_SESSION['username']);
$rcmail_config['default_host'] = $temparr[1];
... same for SMTP settings.