~deavmi/butterflyd

2f204f0e833e9ed710919890cef31e4194a6fa5b — Tristan B. Kildaire 6 months ago 1c43e05
Fixed error report sending code placement.
1 files changed, 22 insertions(+), 21 deletions(-)

M source/client/client.d
M source/client/client.d => source/client/client.d +22 -21
@@ 675,34 675,35 @@ public final class ButterflyClient : Thread
                }
            }

            /**
            * If there are failed sends then send an error message
            * to the sender.
            */
            if(failedRecipients.length)
            {
                /* Create the error message */
                JSONValue deliveryReport;
                JSONValue[] errorRecipients = [JSONValue(mailbox.username~"@"~server.domain)];
                deliveryReport["recipients"] = errorRecipients;
            writeln("Sent mail message");
        }

                /* TODO: Make more indepth, and have copy of the mail that was tried to be sent */
                string errorMessage = "There was an error delivery the mail to: "~to!(string)(recipients)~"\n";
                errorMessage ~= "\nThe message was:\n\n"~mailBlock.toPrettyString();
                deliveryReport["message"] = errorMessage;
        writeln("Mail delivered");

                writeln(deliveryReport);
        /**
        * If there are failed sends then send an error message
        * to the sender.
        */
        if(failedRecipients.length)
        {
            /* Create the error message */
            JSONValue deliveryReport;
            JSONValue[] errorRecipients = [JSONValue(mailbox.username~"@"~server.domain)];
            deliveryReport["recipients"] = errorRecipients;

                /* Deliver the error message */
                sendMail(deliveryReport);
            /* TODO: Make more indepth, and have copy of the mail that was tried to be sent */
            string errorMessage = "There was an error delivery the mail to: "~to!(string)(recipients)~"\n";
            errorMessage ~= "\nThe message was:\n\n"~mailBlock.toPrettyString();
            deliveryReport["message"] = errorMessage;

                writeln("Mail delivery report sent: "~deliveryReport.toPrettyString());
            }
            writeln(deliveryReport);

            writeln("Sent mail message");
            /* Deliver the error message */
            sendMail(deliveryReport);

            writeln("Mail delivery report sent: "~deliveryReport.toPrettyString());
        }

        writeln("Mail delivered");

        /* Store the message in this user's "Sent" folder */
        Folder sentFolder = new Folder(mailbox, "Sent");