Base64: java.lang.IllegalArgumentException: Illegal character

Your encoded text is [B@6499375d. That is not Base64, something went wrong while encoding. That decoding code looks good. Use this code to convert the byte[] to a String before adding it to the URL: String encodedEmailString = new String(encodedEmail, “UTF-8”); // … String confirmLink = “Complete your registration by clicking on following” + “\n<a … Read more

Using JavaMail with TLS

We actually have some notification code in our product that uses TLS to send mail if it is available. You will need to set the Java Mail properties. You only need the TLS one but you might need SSL if your SMTP server uses SSL. Properties props = new Properties(); props.put(“mail.smtp.starttls.enable”,”true”); props.put(“mail.smtp.auth”, “true”); // If … Read more

Where to find all available Java mail properties?

In the api is a reference to the properties for the specific sun protocol providers. Not sure if you were looking for these: https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.html https://javaee.github.io/javamail/docs/api/com/sun/mail/pop3/package-summary.html https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html These are also set on the session object but you use them on your own risk since in other mail implementations they are maybe not supported or they change … Read more

how to send HTML email

Don’t upcast your MimeMessage to Message: MimeMessage simpleMessage = new MimeMessage(mailSession); Then, when you want to set the message body, either call simpleMessage.setText(text, “utf-8”, “html”); or call simpleMessage.setContent(text, “text/html; charset=utf-8”); If you’d rather use a charset other than utf-8, substitute it in the appropriate place. JavaMail has an extra, useless layer of abstraction that often … Read more

UTF-8 charset doesn’t work with javax.mail

For all e-mails There are a couple of system properties related to mailing, that can probably simplify your code. I am talking about this specific property actually: “mail.mime.charset”. The mail.mime.charset System property can be used to specify the default MIME charset to use for encoded words and text parts that don’t otherwise specify a charset. … Read more

How to read text inside body of mail using javax.mail

This answer extends yurin’s answer. The issue he brought up was that the content of a MimeMultipart may itself be another MimeMultipart. The getTextFromMimeMultipart() method below recurses in such cases on the content until the message body has been fully parsed. private String getTextFromMessage(Message message) throws MessagingException, IOException { if (message.isMimeType(“text/plain”)) { return message.getContent().toString(); } … Read more

javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted

Sorry for coming late to Party.These could be the problem in your task if you are using Gmail Server. Two Step Verification should be turned off. Allow Less Secure App(should be turned on). Please Check Your UserName and Password. Check the code(which was my Problem), Above three You can change form google help center and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)