手机上怎么建网站,网站如何做静态化,wordpress支付接口吗,佛山网站建设公司大全项目场景#xff1a; java mail集成james邮件服务器#xff0c;发送邮件时需要判断邮件是否发送成功。我们会发现JavaMail给用户发送邮件#xff0c;但是调用Transport类的sendMessage方法发送的邮件是没有返回值的#xff0c;所以判断不了。 但是我们可以用另一个解决方案…项目场景 java mail集成james邮件服务器发送邮件时需要判断邮件是否发送成功。我们会发现JavaMail给用户发送邮件但是调用Transport类的sendMessage方法发送的邮件是没有返回值的所以判断不了。 但是我们可以用另一个解决方案就是采用“系统退信”的方式来达到目的我们会发现163、qq等邮件发送失败就会“系统退信”。 需求
什么情况下会系统退信
邮箱地址错误或访问不通邮箱地址正确但是用户不存在 解决方案 修改james配置windows文件路径james\apps\james\SAR-INF\config.xml搜索关键字maxRetries 原内容
mailet matchAll classRemoteDeliveryoutgoingfile://var/mail/outgoing//outgoing!-- Delivery Schedule based upon RFC 2821, 4.5.4.1 --!-- 5 day retry period, with 4 attempts in the firsthour, two more within the first 6 hours, and thenevery 6 hours for the rest of the period. --delayTime 5 minutes /delayTimedelayTime 10 minutes /delayTimedelayTime 45 minutes /delayTimedelayTime 2 hours /delayTimedelayTime 3 hours /delayTimedelayTime 6 hours /delayTimemaxRetries 25 /maxRetries!-- The number of threads that should be trying to deliver outgoing messages --deliveryThreads 50 /deliveryThreads!-- If false the message will not be sent to given server if any recipients fail --sendpartialfalse/sendpartial!-- By default we send bounces to the bounce processor --!-- By removing this configuration James will fallback to hardcoded bounce --!-- notifications --bounceProcessorbounces/bounceProcessor
/mailet
修改后的内容
mailet matchAll classRemoteDeliveryoutgoingfile://var/mail/outgoing//outgoing!-- Delivery Schedule based upon RFC 2821, 4.5.4.1 --!-- 5 day retry period, with 4 attempts in the firsthour, two more within the first 6 hours, and thenevery 6 hours for the rest of the period. --delayTime 1 minutes /delayTimemaxRetries 1 /maxRetries!-- The number of threads that should be trying to deliver outgoing messages --deliveryThreads 50 /deliveryThreads!-- If false the message will not be sent to given server if any recipients fail --sendpartialtrue/sendpartial!-- By default we send bounces to the bounce processor --!-- By removing this configuration James will fallback to hardcoded bounce --!-- notifications --bounceProcessorbounces/bounceProcessor
/mailet
其实就是改了delayTime、maxRetries、sendpartial这三个标签
......delayTime 1 minutes /delayTime
maxRetries 1 /maxRetriessendpartialtrue/sendpartial...... 解析
这段内容就是邮件发送失败重试的机制这个outgoing文件夹里面就是需要重试的邮件 delayTime重试的时间 maxRetries最大重试次数 sendpartial如果为true任何收件人失败会将消息发送到给定的服务器 所以原来默认是
5天重试期第一次尝试4次小时前6小时内再增加两次然后在剩余时间内每6小时一次。
需要重试5天时间太长了
我们改为了1分钟后只重试1次
我测试这应该是最短的间隔了试了0.5minutes和1second好像没效果。 结果 接收退信就平时接收邮件一样就行了在inboxes文件夹 邮箱地址错误或访问不通测试的邮箱地址testtest.com系统退信的邮件内容 Hi. This is the James mail server at XT-PC.
Im afraid I wasnt able to deliver your message to the following addresses.
This is a permanent error; Ive given up. Sorry it didnt work out. Below
I include the list of recipients and the reason why I was unable to deliver
your message.Failed recipient(s):
testtest.comError message:
There are no DNS entries for the hostname test.com. I cannot determine where to send this message.
邮箱地址正确但是用户不存在测试的邮箱地址test1111163.com系统退信的邮件内容 Hi. This is the James mail server at XT-PC.
Im afraid I wasnt able to deliver your message to the following addresses.
This is a permanent error; Ive given up. Sorry it didnt work out. Below
I include the list of recipients and the reason why I was unable to deliver
your message.Failed recipient(s):
test1111163.comError message:
550 User not found: test1111163.com 总结 缺点不能实时反馈发送的结果