使用Javamail以意大利语发送邮件时,等于符号后看到的奇怪字符。有人建议使用javamail以意大利语发送邮件吗?
电子邮件正文如下
Ciao Dibyendu Biswas,
Abbiamo ricevuto una richiesta di reimpostazione della sua password Validac=
tor.
Rei=
mposta Password
Se ignori questo messaggio, la password non verr=C3=A0 reimpostata.
Se non hai richiesto la reimpostazione della password, Comunicacelo
以下是我用来发送邮件的java邮件代码。
public static boolean sendMail (String emailId,String subject,String body,boolean isHtml) {
boolean status = false;
Properties properties = new Properties();
properties.setProperty("mail.smtp.host", "smtp.zoho.com");
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail.smtp.socketFactory.fallback", "false");
properties.setProperty("mail.smtp.port", "465");
properties.setProperty("mail.smtp.socketFactory.port", "465");
properties.setProperty( "mail.pop3.socketFactory.fallback", "false");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.auth", "true");
properties.put("mail.debug", "true");
properties.put("mail.store.protocol", "pop3");
properties.put("mail.transport.protocol", "smtp");
properties.put("mail.debug.auth", "true");
javax.mail.Session session = javax.mail.Session.getInstance(properties,new javax.mail.Authenticator()
{ @Override
protected PasswordAuthentication getPasswordAuthentication()
{ return new PasswordAuthentication(ProductValidationSystemWebConstants.VALIDACTOR_SUPPORT_EMAILID,ProductValidationSystemWebConstants.VALIDACTOR_SUPPORT_PASSWORD);
}
});
try
{ MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(ProductValidationSystemWebConstants.VALIDACTOR_SUPPORT_EMAILID));
message.setRecipients(MimeMessage.RecipientType.TO,InternetAddress.parse(emailId));
message.setSubject(subject);
if(isHtml) {
System.out.println("mail body before: "+body);
message.setText(body,"UTF-8", "html");
System.out.println("mail body after: "+body);
}
else
message.setText(body);
Transport.send(message);
status = true;
}
catch (MessagingException e)
{
e.printStackTrace();
}
return status;
}
我用gmail来阅读邮件。如果邮件内容中有任何意大利字符,则会出现问题。