JavaMail-通过身份验证发送
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaMail-通过身份验证发送相关的知识,希望对你有一定的参考价值。
Simple Mail Example.Tags: SMTP, Mail, Java
[JavaMail (Sun)](http://java.sun.com/products/javamail/)
[JavaMail (Galileo)](http://openbook.galileocomputing.de/javainsel8/javainsel_18_012.htm#mj2a4110a634c82a3f676d8f87a50d6567)
import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class JavaMail { String subject, throws MessagingException { props.put( "mail.smtp.host", "mySMTPHost" ); props.put( "mail.smtp.auth","true"); } }; Session session = Session.getDefaultInstance( props , authenticator); Message msg = new MimeMessage( session ); InternetAddress addressFrom = new InternetAddress( from ); msg.setFrom( addressFrom ); InternetAddress addressTo = new InternetAddress( recipient ); msg.setRecipient( Message.RecipientType.TO, addressTo ); msg.setSubject( subject ); msg.setContent( message, "text/plain" ); Transport.send( msg ); } { postMail( "[email protected]", "mySubject", "myContent", } }
以上是关于JavaMail-通过身份验证发送的主要内容,如果未能解决你的问题,请参考以下文章