简体   繁体   中英

permission denied exception when sending mail javamail

HI When I try to send a mail from java mail I got exception but it will work for one email adddress ("abil"). Please help me.

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");
}

I can send a mail using "abil" as sender. but when I can send a mail using "bill" as sender I got below exception ,

    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)

Why I cant able to send a mail when the sender is changed to "bill@xyx@abc". I can send a mail if my sender is same as user.

Thank you very much,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM