Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

sending emails with attachements via gmail

by morgon (Priest)
on Mar 12, 2020 at 20:21 UTC ( #11114189=perlquestion: print w/replies, xml ) Need Help??

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

I have been pointed to Re^3: gmail sending in 2020 for sending emails via gmail in the modern age.

However at the moment I cannot figure out how to add attachments to the mail...

Has anybody a working example of how to send emails via gmail with attachments that works in the year 2020 since Christ was born?

I would be so grateful...

  • Comment on sending emails with attachements via gmail

Replies are listed 'Best First'.
Re: sending emails with attachements via gmail
by haukex (Bishop) on Mar 12, 2020 at 21:23 UTC

    Several of the modules in that thread are by RJBS, who has additional modules that can handle attachments, such as Email::Stuffer. Untested, but try something like this instead of the Email::Simple code in that thread:

    Email::Stuffer ->from($smtp{user}) ->to($smtp{to}) ->subject($smtp{subject}) ->text_body($smtp{body}) ->attach_file('example.txt') ->transport($transport) ->send;
Re: sending emails with attachements via gmail
by clueless newbie (Deacon) on Mar 13, 2020 at 11:47 UTC

    From the synopisis of Email::Send::SMTP::Gmail:

    use strict; use warnings; use Email::Send::SMTP::Gmail; my ($mail,$error)=Email::Send::SMTP::Gmail->new( -smtp=>' +m', -login=>'whateveraddr', -pass=>'whatever_pass +'); print "session error: $error" unless ($email!=-1); $mail->send(-to=>'', -subject=>'Hello!', -body=>'Just te +sting it', -attachments=>'full_path_to_file'); $mail->bye;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11114189]
Approved by GrandFather
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2021-01-21 12:11 GMT
Find Nodes?
    Voting Booth?