Created
December 27, 2017 01:58
-
-
Save toliner/06bc522f001e8eb2abd92a1dfebf8fc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
import javax.mail.* | |
import javax.mail.internet.InternetAddress | |
import javax.mail.internet.MimeMessage | |
val ENCODING = "utf-8" | |
val property = Properties() | |
property.setProperty("mail.smtp.host", /*Mail Domain*/"") | |
property.setProperty("mail.smtp.port", "587") | |
property.setProperty("mail.smtp.connectiontimeout", "60000") | |
property.setProperty("mail.smtp.timeout", "60000") | |
property.setProperty("mail.smtp.auth", "true") | |
property.setProperty("mail.smtp.starttls.enable", "true") | |
property.setProperty("mail.smtp.starttls.required", "true") | |
property.setProperty("mail.user", "info") | |
property.setProperty("mail.debug", "true") | |
val session = Session.getInstance(property, object : Authenticator() { | |
override fun getPasswordAuthentication(): PasswordAuthentication { | |
return PasswordAuthentication(/*Mail and password*/) | |
} | |
}) | |
val message = MimeMessage(session) | |
val addressFrom = InternetAddress(/*Mail*/, "Ratya Info", toliner.ratya.ENCODING) | |
message.addFrom(arrayOf(addressFrom)) | |
val addressTo = InternetAddress(/*Mail*/, "トリナー", toliner.ratya.ENCODING) | |
message.addRecipients(Message.RecipientType.TO, arrayOf(addressTo)) | |
message.setSubject("とっととUTF-8で認識されてくれええええええ", toliner.ratya.ENCODING) | |
message.setText("もう疲れたよパトラッシュ", toliner.ratya.ENCODING) | |
message.sentDate = Date() | |
message.setHeader("Content-Type", "text/plain; charset=utf-8") | |
message.writeTo(System.err) | |
Transport.send(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment