class Poco::Net::SMTPChannel

Overview

This Channel implements SMTP (email) logging. More…

#include <SMTPChannel.h>

class SMTPChannel: public Poco::Channel
{
public:
    // fields

    static const std::string PROP_MAILHOST;
    static const std::string PROP_SENDER;
    static const std::string PROP_RECIPIENT;
    static const std::string PROP_LOCAL;
    static const std::string PROP_ATTACHMENT;
    static const std::string PROP_TYPE;
    static const std::string PROP_DELETE;
    static const std::string PROP_THROW;

    // construction

    SMTPChannel();

    SMTPChannel(
        const std::string& mailhost,
        const std::string& sender,
        const std::string& recipient
        );

    // methods

    virtual
    void
    open();

    virtual
    void
    close();

    virtual
    void
    log(const Message& msg);

    virtual
    void
    setProperty(
        const std::string& name,
        const std::string& value
        );

    virtual
    std::string
    getProperty(const std::string& name) const;

    static
    void
    registerChannel();
};

Inherited Members

public:
    // methods

    virtual
    void
    setProperty(
        const std::string& name,
        const std::string& value
        ) = 0;

    virtual
    std::string
    getProperty(const std::string& name) const = 0;

    void
    duplicate() const;

    void
    release() const;

    int
    referenceCount() const;

    virtual
    void
    open();

    virtual
    void
    close();

    virtual
    void
    log(const Message& msg) = 0;

    virtual
    void
    setProperty(
        const std::string& name,
        const std::string& value
        );

    virtual
    std::string
    getProperty(const std::string& name) const;

Detailed Documentation

This Channel implements SMTP (email) logging.

Construction

SMTPChannel()

Creates a SMTPChannel.

SMTPChannel(
    const std::string& mailhost,
    const std::string& sender,
    const std::string& recipient
    )

Creates a SMTPChannel with the given target mailhost, sender, and recipient.

Methods

virtual
void
open()

Opens the SMTPChannel.

virtual
void
close()

Closes the SMTPChannel.

virtual
void
log(const Message& msg)

Sends the message’s text to the recipient.

virtual
void
setProperty(
    const std::string& name,
    const std::string& value
    )

Sets the property with the given value.

The following properties are supported:

* mailhost:   The SMTP server. Default is "localhost".
* sender:     The sender address.
* recipient:  The recipient address.
* local:      If true, local time is used. Default is true.
* attachment: Filename of the file to attach.
* type:       Content type of the file to attach.
* delete:     Boolean value indicating whether to delete
              the attachment file after sending.
* throw:      Boolean value indicating whether to throw
              exception upon failure.
virtual
std::string
getProperty(const std::string& name) const

Returns the value of the property with the given name.

static
void
registerChannel()

Registers the channel with the global LoggingFactory.