Skip to content

Can't send mail from ofApp::exit() #15

@Echolaitoc

Description

@Echolaitoc

I'm trying to send a log of my application when it shuts down.
So I added the following to ofApp::exit():

smtp.send(message);
smtp.waitForThread();

But the application closes before sending the mail.

When I try waiting for the thread without stopping it, the mail gets send but the application freezes and never closes:

smtp.send(message);
smtp.waitForThread(false);

I found a workaround

// in ofApp.h
bool waitForMail;

and

smtp.send(message);
waitForMail = true;
while (waitForMail)
{
    // do nothing
}

and on receiving a SMTP delivery event in ofApp::onSMTPDelivery(ofx::SMTP::Message::SharedPtr& message) setting

waitForThread = false

Is this intendet behaviour? I expected either my first or second approach would have worked. I'm kind of unhappy with my current solution (a while loop with nothing in it...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions