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.
Balakrishnan,
Thanks that is exactly what I was looking for. Although I should have experimented a bit more on this before submitting the question.
Thanks again!