The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SweetPea::Application::Email - Email handling for SweetPea-Application.

SYNOPSIS ... from inside SweetPea::Application or a Controller; $s->email->message({ to => 'me@abc.com', from => 'you@abc.com, subject => 'Have you heard, the bird is the word', message => 'Everybodys heard that the bird is the word', type => 'text', attachments => [ 'avatar.gif' => 'your_photo.gif', 'invoice.xls' => 'invoice.xls' ] })->send;

    $s->email->message({
        to          => 'me@abc.com',
        from        => 'you@abc.com,
        cc          => 'him@abc.com, her@abc.com',
        subject     => 'Have you heard, the bird is the word',
        message     => 'Everybodys heard that the bird is the word',
        webpages    => [
            '/email/letters/welcome' => 'welcome.html',
            '/email/letters/terms'   => 'service_terms.html'
        ]
    })->send;

    # defaults to sendmail, if you want to send using smtp
    $s->email->message->send(uc('smtp'),'mail.domain.tld');

METHODS

new

    The new method instantiates a new SweetPea::Application::Email object
    which use Email::Stuff as a base class to provide a a host of email
    functionality. 
    
    $s->plug( 'email', sub { return SweetPea::Application::Email->new($s); });

message

    The message method provides a unified interface for sending emails via
    the Email::Stuff package.
    
    $s->email->message({
        to          => 'me@abc.com',
        from        => 'you@abc.com,
        subject     => 'Have you heard, the bird is the word',
        message     => 'Everybodys heard that the bird is the word',
        webpages    => [
            '/email/letters/welcome' => 'welcome.html',
            '/email/letters/terms'   => 'service_terms.html'
        ]
    })->send;
    
    # Note! webpage option lets you send the output from a dispatched url using
    SweetPea's mock method e.g.
    
    The exmaple above capture the output from the following request and attaches
    it as a file.
    
    http://localhost/email/letters/welcome

AUTHOR

Al Newkirk, <al.newkirk at awnstudio.com>