Package javax.mail

Examples of javax.mail.Authenticator


          Properties mailProperties = System.getProperties();
          mailProperties.put("mail.smtp.host", smtp_host);
          if(smtp_port>0 && smtp_port!=25)
              mailProperties.put("mail.smtp.port", String.valueOf(smtp_port));
          mailProperties.put("mail.smtp.auth", "true"); //����smtp��֤���ܹؼ���һ��
          mailSession = Session.getDefaultInstance(mailProperties, new Authenticator(){
        protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(smtp_user, smtp_pass);
        }});
    }
    else{
View Full Code Here


    if (smtpHost != null)
    {
      props.put("mail.smtp.host", smtpHost);
    }

    Authenticator auth = null;
   
    if (this.getSmtpUsername() != null)
    {
      auth = new UsernamePasswordAuthenticator(
                    this.getSmtpUsername(),
View Full Code Here

    props.put("mail.smtp.host", host);
    if (mUser != null)
    {
      props.put("mail.smtp.auth", "true");
    }
    Authenticator auth = new MyAuthenticator();
    Session session = Session.getInstance(props, auth);
    try
    {
      /*
       * Creating the message
View Full Code Here

   protected void startService() throws Exception
   {
      // Setup password authentication
      final PasswordAuthentication pa = new PasswordAuthentication(getUser(), getPassword());
      Authenticator a = new Authenticator()
      {
         protected PasswordAuthentication getPasswordAuthentication()
         {
            return pa;
         }
View Full Code Here

   
    Properties properties = new Properties();// 创建Properties对象
    properties.setProperty("mail.transport.protocol", "smtp");// 设置传输协议
    properties.put("mail.smtp.host", "smtp.163.com");// 设置发信邮箱的smtp地址
    properties.setProperty("mail.smtp.auth", "true"); // 验证
    Authenticator auth = new AjavaAuthenticator(emailName,
        emailPassword); // 使用验证,创建一个Authenticator
    Session session = Session.getDefaultInstance(properties, auth);// 根据Properties,Authenticator创建Session
    Message message = new MimeMessage(session);// Message存储发送的电子邮件信息
    message.setFrom(new InternetAddress(fromEmail));
    message.setRecipient(Message.RecipientType.TO, new InternetAddress(
View Full Code Here

    private Authenticator getAuthenticator() {
        final String un = getSmtpAuthUsername();
        if (un == null) {
            return null;
        }
        return new Authenticator() {

            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(getSmtpAuthUsername(), getSmtpAuthPassword());
            }
View Full Code Here

        }

        properties.put("mail.transport.protocol", getTransport());

        // Authentication if required
        Authenticator authenticator = null;
        if (getUsername() != null && getPassword() != null)
        {
            if (isSsl())
            {
                properties.put("mail.smtps.auth", "true");
            }
            else
            {

                properties.put("mail.smtp.auth", "true");
            }
            authenticator = new Authenticator()
            {
                @Override
                protected PasswordAuthentication getPasswordAuthentication()
                {
                    return new PasswordAuthentication(getUsername(), getPassword());
View Full Code Here

        props.put("mail.smtp.port", "587");
        props.put("mail.smtp.starttls.enable", "true");
//Thiết lập account đăng nhập smtp
        final String login = "nguyenduong111090@gmail.com";//usermail
        final String pwd = "duongbum";//”password của bạn ở đây”;
        Authenticator pa = null; //default: no authentication
        if (login != null && pwd != null) { //authentication required?
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
View Full Code Here

        props.put("mail.smtp.port", "587");
        props.put("mail.smtp.starttls.enable", "true");
//Thiết lập account đăng nhập smtp
        final String login = from;//usermail
        final String pwd = psw;//”password của bạn ở đây”;
        Authenticator pa = null; //default: no authentication
        if (login != null && pwd != null) { //authentication required?
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
View Full Code Here

        props.put("mail.smtp.port", "587");
        props.put("mail.smtp.starttls.enable", "true");
//Thiết lập account đăng nhập smtp
        final String login = "nguyenduong111090@gmail.com";//usermail
        final String pwd = "duongbum";//”password của bạn ở đây”;
        Authenticator pa = null; //default: no authentication
        if (login != null && pwd != null) { //authentication required?
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
View Full Code Here

TOP

Related Classes of javax.mail.Authenticator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.