Ignore:
Timestamp:
2017-06-12T11:56:25+12:00 (7 years ago)
Author:
kjdon
Message:

modified to use tls or ssl to send mail if requested

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java

    r30820 r31729  
    556556        password = GlobalProperties.getProperty("mail.smtp.password");
    557557        String from = GlobalProperties.getProperty("mail.from");
    558 
     558        String port = GlobalProperties.getProperty("mail.smtp.port");
     559        String mail_security = GlobalProperties.getProperty("mail.security");
    559560        String mailer = "msgsend";
    560561
     
    580581            }
    581582
     583
     584            if (port != null && !port.trim().equals("")) {
     585                props.put("mail.smtp.port", port);
     586            }
     587           
     588            if (mail_security != null) {
     589                mail_security = mail_security.trim();
     590                if (mail_security.equals("ssl")) {
     591                props.put("mail.smtp.ssl.enable", "true");
     592                } else if (mail_security.equals("tls")) {
     593                props.put("mail.smtp.starttls.enable", "true");
     594                }
     595                else if (mail_security.equals("")) {
     596                logger.error("unknown security protocol "+mail_security +", should be ssl or tls");
     597                }
     598            }
     599
     600            // this doesn't seem to matter having this when
     601            // username and password are empty
     602            props.put("mail.smtp.auth", "true");
     603
    582604            //setup username and password to the smtp server
     605           
    583606            if (username == null || username.trim().equals(""))
    584607                username = "";
    585608            if (password == null || password.trim().equals(""))
    586609                password = "";
     610           
    587611            Authenticator auth = new Authenticator()
    588612            {
     
    619643        catch (Exception e)
    620644        {
    621             e.printStackTrace();
    622             result.appendChild(result_doc.createTextNode(e.getMessage()));
     645            logger.error("Error sending mail!");
     646            e.printStackTrace();
     647            result.appendChild(result_doc.createTextNode(e.getMessage()));
    623648        }
    624649
Note: See TracChangeset for help on using the changeset viewer.