Project

General

Profile

« Previous | Next » 

Revision 59805

[User Management]: Update registered service table and methods

View differences:

EmailSender.java
29 29
        properties.put("mail.transport.protocol", "smtp");
30 30
        properties.put("mail.smtp.host", host);
31 31
        properties.put("mail.smtp.port", port);
32
        properties.put("mail.smtp.auth", "false"); //enable authentication
33
        //properties.put("mail.smtp.starttls.enable", "true");
34
        //properties.put("mail.smtp.ssl.trust", "*");
35

  
36 32
        //Dev for sending email from gmail
37
        /*
38
        properties.put("mail.smtp.auth", "true"); //enable authentication
39
        properties.put("mail.smtp.starttls.enable", "true");
40
        properties.put("mail.smtp.ssl.trust", "*");
41
        */
33
        if(host.equals("smtp.gmail.com")) {
34
            properties.put("mail.smtp.auth", "true"); //enable authentication
35
            properties.put("mail.smtp.starttls.enable", "true");
36
            properties.put("mail.smtp.ssl.trust", "*");
37
        } else {
38
            properties.put("mail.smtp.auth", "false");
39
        }
42 40
        Session session = javax.mail.Session.getInstance(properties,
43
            new Authenticator() {
44
                protected PasswordAuthentication getPasswordAuthentication() {
45
                    return new PasswordAuthentication(username, password);
46
                }
47
            });
41
                new Authenticator() {
42
                    protected PasswordAuthentication getPasswordAuthentication() {
43
                        return new PasswordAuthentication(username, password);
44
                    }
45
                });
48 46

  
49
            // Create a default MimeMessage object.
50
            MimeMessage message = new MimeMessage(session);
47
        // Create a default MimeMessage object.
48
        MimeMessage message = new MimeMessage(session);
51 49

  
52
            // Set From: header field of the header.
53
            message.setFrom(new InternetAddress(from));
50
        // Set From: header field of the header.
51
        message.setFrom(new InternetAddress(from));
54 52

  
55
            // Set To: header field of the header.
56
            message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
53
        // Set To: header field of the header.
54
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
57 55

  
58
            // Set Subject: header field
59
            message.setSubject(subject, "UTF-8");
56
        // Set Subject: header field
57
        message.setSubject(subject, "UTF-8");
60 58

  
61
            // For simple text setText() can be used instead of setContent()
59
        // For simple text setText() can be used instead of setContent()
62 60

  
63
            // Send the actual HTML message, as big as you like
64
            message.setContent(body, "text/html;charset=UTF-8");
61
        // Send the actual HTML message, as big as you like
62
        message.setContent(body, "text/html;charset=UTF-8");
65 63

  
66
            // Send message
67
            Transport.send(message);
68
            logger.debug("Sent message successfully....\n");
64
        // Send message
65
        Transport.send(message);
66
        logger.debug("Sent message successfully....\n");
69 67

  
70 68
    }
71 69

  

Also available in: Unified diff