我目前使用這個腳本來發送客戶郵件。但收件箱中的「發件人」名稱顯示爲: [email protected]。我想把這個名字設置爲Full House。我怎麼做?從java郵件中的名字設置
public Mail(Speler speler) throws MessagingException {
final String username = "[email protected]";
final String password = "password";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("Full House"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(speler.email));
message.setSubject("Bevestiging van betaling " + "- Toernooi: " + speler.ToernooiID);
message.setText("Geachte heer/mevrouw " + speler.naam + ","
+ "\n\n Uw betaling voor toernooi: " + speler.ToernooiID + " is geaccepteerd."
+ "\n\n Met vriendelijke groet,"
+ "\n Full House");
Transport.send(message);
System.out.println("Done");
}
}
請在問問題之前先搜索。您的問題的解決方案在http://stackoverflow.com/questions/1567467/setting-the-from-name-in-a-javax-mail-mimemessage – dirkk