line which is having the mistake :
$smtp->to('$emailid\@address.com');
proper line :
$smtp->to("$emailid\@address.com");
if you are using the single quotes for the string, then you have to use the eval to get value of variables used inside. Else you can go with double quotes.