如何更正无效协议:使用javax.mail发送邮件为空
作者:互联网
我正试图以这种方式发送邮件:
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "out.alice.it");
props.setProperty("mail.user", "mymail@domain.it");
props.setProperty("mail.password", "*****");
Session mailSession = Session.getDefaultInstance(props, null);
Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress("Host", "Name"));
在行传输传输…我检索此错误:
javax.mail.NoSuchProviderException: Invalid protocol: null
at javax.mail.Session.getProvider(Session.java:440)
at javax.mail.Session.getTransport(Session.java:659)
at javax.mail.Session.getTransport(Session.java:640)
at javax.mail.Session.getTransport(Session.java:626)
at Mail.sendMail(Mail.java:151)
我怎么解决?有人能帮我吗?谢谢!!
标签:java,javax-mail,nosuchproviderexception 来源: https://codeday.me/bug/20190902/1787714.html