Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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 (Chancellor) 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=>'smtp.gmail.co +m', -login=>'whateveraddr +ess@gmail.com', -pass=>'whatever_pass +'); print "session error: $error" unless ($email!=-1); $mail->send(-to=>'target@xxx.com', -subject=>'Hello!', -body=>'Just te +sting it', -attachments=>'full_path_to_file'); $mail->bye;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2020-05-29 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (171 votes). Check out past polls.

    Notices?