G'day IvanH,
As ++roboticus has pointed out, your core problem is the constructor (new()) failing.
Here's some troubleshooting tips.
-
Add "-debug => 1" to new()'s argument list.
-
Check that Email::Send::SMTP::Gmail's default for -smtp (i.e. smtp.gmail.com) is valid for you.
-
Check spelling of -login value.
-
Check spelling of -pass value (i.e. "my real password").
-
Check that the password you're using doesn't have special characters (e.g. '$' and '@') that haven't been escaped.
-
Always check the return value of new() (both while debugging and in production code).
If $mail is not a Email::Send::SMTP::Gmail object, provide appropriate feedback and exit your script gracefully.
[The following is not documented as part of the published API, so don't rely on it remaining the same in future versions; however, looking at the latest (v0.85) source code, $mail with have a value of -1 if connection to the SMTP server failed.]