Poco::OSP::Mail

class MailDeliveryHandle

Library: OSP/Mail
Package: Mail
Header: Poco/OSP/Mail/MailDeliveryService.h

Description

This class contains status information about an email message delivery. It also provides events for asynchronous notification about delivery status.

Inheritance

Direct Base Classes: Poco::Notification

All Base Classes: Poco::Notification, Poco::RefCountedObject

Member Summary

Member Functions: exception, message, status, tryWait, updateStatus, wait

Inherited Functions: duplicate, name, referenceCount, release

Types Aliases

Ptr

using Ptr = Poco::AutoPtr < MailDeliveryHandle >;

Enumerations

MailStatus

MAIL_QUEUED

The mail message has been queued for delivery.

MAIL_DELIVERING

The mail message is being delivered to the SMTP server.

MAIL_DELIVERED

The mail message has been successfully delivered to the SMTP server.

MAIL_FAILED

The mail message could not be sent.

Constructors

MailDeliveryHandle

explicit MailDeliveryHandle(
    MailMessagePtr pMessage
);

Creates the MailDeliveryHandle.

Destructor

~MailDeliveryHandle virtual

~MailDeliveryHandle();

Destroys the MailDeliveryHandle.

Member Functions

exception inline

ExceptionPtr exception() const;

Returns the exception if mail delivery failed, or a null pointer otherwise.

message inline

MailMessagePtr message() const;

Returns the mail message.

status inline

MailStatus status() const;

Returns the current status.

tryWait

bool tryWait(
    long milliseconds
);

Waits for the mail message to be delivered to the SMTP server.

Returns true if the mail message was delivered (or delivery failed), false otherwise.

After this method returns, call status() to check whether delivery was successful.

wait

void wait();

Waits for the mail message to be delivered to the SMTP server.

After this method returns, call status() to check whether delivery was successful.

wait

void wait(
    long milliseconds
);

Waits for the mail message to be delivered to the SMTP server.

Throws a Poco::TimeoutException if the message could not be delivered within the given timeout.

After this method returns, call status() to check whether delivery was successful.

updateStatus protected

void updateStatus(
    MailStatus status
);

Updates the status and signals the event if the status is MAIL_DELIVERED or MAIL_FAILED.

updateStatus protected

void updateStatus(
    const Poco::Exception & exc
);

Sets the status to MAIL_FAILED and stores a copy of the exception.

Variables

messageDelivered

Poco::BasicEvent < const Ptr > messageDelivered;

Fired when the message was delivered successfully.

messageDelivering

Poco::BasicEvent < const Ptr > messageDelivering;

Fired when the message is about to be delivered.

messageFailed

Poco::BasicEvent < const Ptr > messageFailed;

Fired when sending the message has failed.