Package javax.mail

Examples of javax.mail.Session


    {
        // Create some properties and get the default Session.
        Properties props = new Properties();
        props.put("mail.smtp.host", host);

        Session session = Session.getInstance(props, null);
        session.setDebug(debug);

        try
        {
            // Create a message.
            Message msg = new MimeMessage(session);
View Full Code Here


        throws Exception {

        Properties props = new Properties();
        props.setProperty("mail.host", "mail.optonline.net");

        Session session = Session.getDefaultInstance(props);

        session.setDebug(true);

        SMTPTransport t = new SMTPTransport(session, null);

        MimeMessage msg = new MimeMessage(session);
View Full Code Here

 
  public void sendEmail(String subject, StringBuffer emailBody)
  {
    String[] to = {"eurostat-updates@lists.deri.org"};
   
    Session session = Session.getDefaultInstance(props, null);
      MimeMessage message = new MimeMessage(session);
    
      try{
        message.setFrom(new InternetAddress(from));
    
        InternetAddress[] toAddress = new InternetAddress[to.length];
        for( int i=0; i < to.length; i++ ) {
            toAddress[i] = new InternetAddress(to[i]);
        }
       
        for( int i=0; i < toAddress.length; i++) {
            message.addRecipient(Message.RecipientType.TO, toAddress[i]);
        }
       
        message.setSubject(subject);
        message.setText(emailBody.toString());
        Transport transport = session.getTransport("smtp");
        transport.connect(host, from, pass);
        transport.sendMessage(message, message.getAllRecipients());
        transport.close();
     
     }catch(MessagingException ex)
View Full Code Here

     * Send an email notice that a new pending entry has been submitted.
     */
    public static void sendPendingEntryNotice(WeblogEntry entry)
            throws WebloggerException {
       
        Session mailSession = WebloggerStartup.getMailProvider().getSession();
        if(mailSession == null) {
            throw new WebloggerException("Couldn't get mail Session");
        }
       
        try {
View Full Code Here

     */
    public static void sendWeblogInvitation(Weblog website,
                                            User user)
            throws WebloggerException {
       
        Session mailSession = WebloggerStartup.getMailProvider().getSession();
        if(mailSession == null) {
            throw new WebloggerException("ERROR: Notification email(s) not sent, "
                    + "Roller's mail session not properly configured");
        }
       
View Full Code Here

     * Send a weblog invitation email.
     */
    public static void sendUserActivationEmail(User user)
            throws WebloggerException {
       
        Session mailSession = WebloggerStartup.getMailProvider().getSession();
        if(mailSession == null) {
            throw new WebloggerException("ERROR: Notification email(s) not sent, "
                    + "Roller's mail session not properly configured");
        }
       
View Full Code Here

        MailProvider mailProvider = WebloggerStartup.getMailProvider();
        if(mailProvider == null) {
            return;
        }
       
        Session session = mailProvider.getSession();
        Message message = new MimeMessage(session);
       
        // n.b. any default from address is expected to be determined by caller.
        if (! StringUtils.isEmpty(from)) {
            InternetAddress sentFrom = new InternetAddress(from);
View Full Code Here

    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(
        toEmail));// 设置收信邮箱
    // 指定邮箱内容及ContentType和编码方式
View Full Code Here

        MimeMessage msg;

        // If not overriding global settings, use the Mailer class to create a session and set the from address
        // Else we'll do it ourselves
        Session session;
        if (!overrideGlobalSettings) {
            debug(context.getListener().getLogger(), "NOT overriding default server settings, using Mailer to create session");
            session = Mailer.descriptor().createSession();
            msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(JenkinsLocationConfiguration.get().getAdminAddress()));
        } else {
            debug(context.getListener().getLogger(), "Overriding default server settings, creating our own session");
            session = descriptor.createSession();
            msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(descriptor.getAdminAddress()));
        }

        if (descriptor.isDebugMode()) {
            session.setDebugOut(context.getListener().getLogger());
        }

        String charset = Mailer.descriptor().getCharset();
        if (overrideGlobalSettings) {
            String overrideCharset = descriptor.getCharset();
View Full Code Here

  }
 
  private void sendEmail(String from, String to, String subject, String body) {
    Properties props = new Properties();
    props.put("mail.smtp.host", smtpHost);
    Session session = Session.getInstance(props, null);
    try {
        MimeMessage msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(from));
        msg.addRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
        msg.setSubject(subject);
View Full Code Here

TOP

Related Classes of javax.mail.Session

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.