发送邮件javamail时权限被拒绝异常

时间:2016-12-22 07:31:53

标签: java email javamail

HI当我尝试从java邮件发送邮件时,我得到了例外,但它适用于一个电子邮件地址(“abil”)。请帮帮我。

String smtpServer = "mail.xxxxxx.yy" ;
String user =  abil;
String password = password;
String sPort = "";
String sSSL = "";
String hostName = "";


Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", smtpServer);
props.put("mail.from", from);
props.put("mail.debug", useDebug ? "true" : "false");
props.put("mail.smtp.port", port);
if (hostName != null && !hostName.trim().isEmpty()) {
props.put("mail.smtp.localhost", hostName);
}
if (!user.trim().isEmpty()) {
props.put("mail.user", user);
props.put("mail.smtp.auth", "true");
}
if (usingSSL) {
props.put("mail.smtp.ssl.enable", "true");
}

我可以使用“abil”作为发件人发送邮件。但是当我使用“账单”作为发件人发送邮件时我得到了以下异常,

    22/12/2016 06:56:04.956 - Emailer [INFO] : Properties: {mail.smtp.port=25, mail.debug=true, mail.from=bill, mail.transport.protocol=smtp, mail.user=abil, mail.smtp.auth=true, mail.smtp.host=mail.xxxxxx.yy}
22/12/2016 06:56:04.958 - Emailer [EXCEPTION] : Exception Occurred
org.apache.geronimo.javamail.transport.smtp.SMTPSendFailedException: 5.7.1 <bil@......xy>... Permission denied
        at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendMessage(SMTPTransport.java:486)
        at javax.mail.Transport.send(Transport.java:95)
        at javax.mail.Transport.send(Transport.java:48)
        at modules.email.Emailer.lambda$sendEmail$150(Emailer.java:222)
        at util.ThreadPool$TaskWrapper.run(ThreadPool.java:32)
        at util.ThreadPool$WorkerThread.run(ThreadPool.java:139)
        at java.lang.Thread.run(Unknown Source)

当发件人更改为“bill @ xyx @ abc”时,为什么我无法发送邮件。 如果发件人与用户相同,我可以发送邮件。

非常感谢,

1 个答案:

答案 0 :(得分:0)

发件人'帐单'可能没有发送邮件的权限