Package javax.mail

Examples of javax.mail.Authenticator


        // create some properties and get the default Session
        Properties props = new Properties();

        props.put(MAIL_SMTP_HOST, smtpHost);
        props.put(MAIL_SMTP_PORT, smtpPort); // property values are strings
        Authenticator authenticator = null;
        if(mailAuthType != MailAuthType.NONE) {
            props.put(MAIL_SMTP_AUTH, "true");
            switch (mailAuthType) {
                case SSL:
                    props.put(MAIL_SMTP_SOCKETFACTORY_CLASS,
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(attr.getType(), (String) attr.getContent());
                    }

                    Authenticator auth = null;
                    if (password != null) {
                        String user = props.getProperty("mail.smtp.user");
                        if(user == null) {
                            user = props.getProperty("mail.user");
                        }
                       
                        if(user != null) {
                            final PasswordAuthentication pa = new PasswordAuthentication(user, password);
                            auth = new Authenticator() {
                                    protected PasswordAuthentication getPasswordAuthentication() {
                                        return pa;
                                    }
                                };
                        }
View Full Code Here

                        }

                        props.put(attr.getType(), (String) attr.getContent());
                    }

                    Authenticator auth = null;
                    if (password != null) {
                        String user = props.getProperty("mail.smtp.user");
                        if(user == null) {
                            user = props.getProperty("mail.user");
                        }
                       
                        if(user != null) {
                            final PasswordAuthentication pa = new PasswordAuthentication(user, password);
                            auth = new Authenticator() {
                                    protected PasswordAuthentication getPasswordAuthentication() {
                                        return pa;
                                    }
                                };
                        }
View Full Code Here

    /**
     * Returns an authenticator object for use in sessions
     */
    public Authenticator getAuthenticator() {
        return new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(getUsername(), getPassword());
            }
        };
    }
View Full Code Here

                        }

                        props.put(attr.getType(), attr.getContent());
                    }

                    Authenticator auth = null;
                    if (password != null) {
                        String user = props.getProperty("mail.smtp.user");
                        if(user == null) {
                            user = props.getProperty("mail.user");
                        }
                       
                        if(user != null) {
                            final PasswordAuthentication pa = new PasswordAuthentication(user, password);
                            auth = new Authenticator() {
                                    @Override
                                    protected PasswordAuthentication getPasswordAuthentication() {
                                        return pa;
                                    }
                                };
View Full Code Here

        // create some properties and get the default Session
        Properties props = new Properties();

        props.put(MAIL_SMTP_HOST, smtpHost);
        props.put(MAIL_SMTP_PORT, smtpPort); // property values are strings
        Authenticator authenticator = null;
        if(mailAuthType != MailAuthType.NONE) {
            props.put(MAIL_SMTP_AUTH, "true");
            switch (mailAuthType) {
                case SSL:
                    props.put(MAIL_SMTP_SOCKETFACTORY_CLASS,
View Full Code Here

            props.put("mail.user", user);
            props.put("mail.host", host);
            props.put("mail.store.protocol", "pop3");
            props.put("mail.transport.protocol", "smtp");
            props.put("mail.smtp.port", smtpPort);
            Session session = Session.getInstance(props, new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return authentication;
                }
            });
View Full Code Here

            props.put("mail.user", user);
            props.put("mail.host", host);
            props.put("mail.store.protocol", "pop3");
            props.put("mail.transport.protocol", "smtp");
            props.put("mail.pop3.port", popPort);
            Session session = Session.getInstance(props, new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return authentication;
                }
            });
View Full Code Here

        if (mail != null && transmitionEnd)
            return MailSrvConstants.COMMAND_TRANSMISSION_END;

        if (input.startsWith("MAIL")) {
            mail = new MimeMessage(Session.getInstance(new Properties(),
                    new Authenticator() {
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return null;
                        }
                    }));
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.