开发者

E-mail sent with commons-mail is *sometimes* not received. How can I troubleshoot?

When I send out an e-mail and it isn't received, how can I figure out what the cause of the problem is?

My app sends e-mails through SMTP using the Apache commons-mail library. For testing purposes, I am using the gmail SMTP server. (Our production app uses an internal server on our network).

In one case on the test server, I have a batch job that generates 5 e-mails with attachments. Some e-mails are received and others are marked as sent, but never appear in my inbox. There doesn't seem to be a pattern to which e-mails are received and which ones silently vanish.

The code that sends and checks for errors looks like this:

    final Mail mail = ...;
                //The Mail class is our app's mail object, which provides data used to generate the MIME e-mail and record the results.
    final MultiPartEmail email = ...;
    try {
        email.setSentDate(mail.getDateSent());
        email.send();
    }
    catch (EmailException ee) {
        success = false;
        mail.setDateSent(null);

        getLog().error("Mail not sent: ", ee);
        if (ee.getMessage().indexOf("receiver address required") != -开发者_StackOverflow社区1) {
            mail.setErrorMessage(ee.getMessage());
            getLog().error(mail.toString());
        }
    }

In the debugger, I determine that no exception is thrown.

My first guess was that the attachment size is too large; but, gmail supposedly supports 25MB attachments, and my largest attachment is 14.3 MB. In some cases when I run the entire batch of 5 e-mails, the e-mail with the largest attachment gets through, and the smaller ones disappear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜