IvanH has asked for the wisdom of the Perl Monks concerning the following question:

I am setting up a PERL program using Email::Send::SMTP::Gmail to send emails with attachemnts on a Windows 8 machine. I have everything working except the attachment. The parameters look like:

my $mail=Email::Send::SMTP::Gmail->new( -smtp=>'smtp.gmail.com', -layer=>'ssl', -port=>465, -login=>'IHipschman@gmail.com' +, -attachments=>'C:\Users\Ivan\D +ocuments\BSA\EMAIL\Fliers\Gmail\CurrentFlier.pdf', -pass=>'password');

For the attachments path I have tried all combinations of single and double quotes, backslashes, double backslashes and forward slashes and none seem to work. The email gets sent but there is no attachment. Can anyone suggest what I am doing wrong?

Thanks, Ivan

Replies are listed 'Best First'.
Re: Sending an attachment with Email::Send::SMTP::Gmail
by AppleFritter (Vicar) on Aug 06, 2014 at 18:00 UTC

    You're passing the -attachments to the wrong method -- specifically, to the constructor, not the ->send call on the mail object it returns. Try changing that.

    If it still doesn't work after that, try passing -verbose => '1' as an extra parameter and see what debug messages you get; perhaps there'll be a clue there.

      Pure stupidity on my part. Passing it to the right method fixed it.

      Thanks

Re: Sending an attachment with Email::Send::SMTP::Gmail
by roboticus (Chancellor) on Aug 06, 2014 at 18:01 UTC

    IvanH:

    The Email::Send::SMTP::Gmail docs don't indicate that attachments is a valid argment for the new method, but instead for the send method. Have you tried specifying the attachment(s) in the send method?

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.