Ok, I see what is going on here. This is a scope issue. The variable you have defined does not have scope inside of the function that is defined on line 8 of sendmail.php. This is a php scope related issue. In order to use a variable inside of a function it must be passed in as a parameter of the function.
The function gets passed the $WA_Auth_Parameter array as the parameter. If you want to use a variable for the mail server like this you would need to add in your variable to the creation of this $WA_Auth_Parameter array that starts on line 16. The values in this array are defined as:
"name" => $value,
So you could add in the mailserver like this:
$WA_Auth_Parameter = array(
"mailserver" => $mailserver,
"connection" => $connTest,
"database" => $database_connTest,
"tableName" => "users",
"filterColumn" => "username",
Once you have added it like this you can reference it on line 9 like this:
subject"]
$WA_MailObject = WA_SecurityAssist_Definition($WA_Auth_Parameter["mailserver"],"25","","","","utf-8");