Note that there are some explanatory texts on larger screens.

plurals
  1. POutf 8 charset doesn't work with javax mail
    primarykey
    data
    text
    <p>I have used Javax Mail API, for sending emails. I am using a contact formular to send the input, which has to be send to a specific email.</p> <p>The email is send without problems, though I am a danish guy, and I am therefore in need of three danish characters which is 'æ', 'ø' and 'å', in the subject and the email text.</p> <p>I have therefore seen that I can use UTF-8 character encoding, to provide these characters, but when my mail is send I only see some strange letters - 'ã¦', 'ã¸' and 'ã¥' - instead of the danish letters - 'æ', 'ø' and 'å'.</p> <p>My method to send the email is looking like this</p> <pre><code>public void sendEmail(String name, String fromEmail, String subject, String message) throws AddressException, MessagingException, UnsupportedEncodingException, SendFailedException { //Set Mail properties Properties props = System.getProperties(); props.setProperty("mail.smtp.starttls.enable", "true"); props.setProperty("mail.smtp.host", "smtp.gmail.com"); props.setProperty("mail.smtp.socketFactory.port", "465"); props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.setProperty("mail.smtp.auth", "true"); props.setProperty("mail.smtp.port", "465"); Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("my_username", "my_password"); } }); //Create the email with variable input MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setHeader("Content-Type", "text/plain; charset=UTF-8"); mimeMessage.setFrom(new InternetAddress(fromEmail, name)); mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("my_email")); mimeMessage.setSubject(subject, "utf-8"); mimeMessage.setContent(message, "text/plain"); //Send the email Transport.send(mimeMessage); } </code></pre> <p>Please help me find out how I can correct this 'error'.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload