아래 코드를 사용하면 영어가 아닌 이메일을 보낼 수 있습니다. 제목이 올바르게 표시되지만 본문이 횡설수설하는 것으로 보입니다.
아이디어가 있으십니까? 편집이 text/plain
로 변경영어 이외의 문자를 인코딩하는 자바 메일
msg.setContent(message, "text/plain; charset=UTF-8");
:
당신에게
public void postMail(String recipient, String subject, String message, String from) throws MessagingException, UnsupportedEncodingException {
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "mail.infodim.gr");
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress addressTo=new InternetAddress(recipient);
msg.setRecipient(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
어떻게 utf-8을 인코딩 할 대상을 설정 했습니까? – user3014926