Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void sendEmail(String address, Integer entityId, String messageKey, String attachmentFileName, String[] params) {
- String smptserver = com.sapienter.jbilling.common.Util.getSysProp("smtp_server") + ":" + com.sapienter.jbilling.common.Util.getSysProp("smtp_port");
- String username = com.sapienter.jbilling.common.Util.getSysProp("smtp_username");
- String password = com.sapienter.jbilling.common.Util.getSysProp("smtp_password");
- String from = com.sapienter.jbilling.common.Util.getSysProp("email_from");
- EntityBL entity = new EntityBL(entityId);
- Locale locale = entity.getLocale();
- ResourceBundle rBundle = ResourceBundle.getBundle("entityNotifications", locale);
- String subject = rBundle.getString(messageKey + "_subject");
- String message = rBundle.getString(messageKey + "_body");
- if (params != null) {
- for (int f = 0; f < params.length; f++) {
- message = message.replaceFirst("\\|X\\|", params[f]);
- }
- }
- String statement = "echo \"" + message + "\"" +
- " | mailx -v -s \"" + subject + "\"" +
- " -S smtp=smtp://" + smptserver +
- " -S smtp-auth-user=" + username +
- " -S smtp-auth-password=" + password +
- " -S nss-config-dir=/home/capgemini/.mozilla/firefox/7cl9hq4v.default/" +
- " -S ssl-verify=ignore -S smtp-use-starttls" +
- " -S from=" + from +
- " -a " + attachmentFileName +
- " " + address;
- File tempfile = getScript(statement);
- LOG.debug("ALD: statement=[" + statement + "]");
- try {
- String command = "sh " + tempfile.getPath();
- LOG.debug("ALD: executing command=[" + command + "]");
- Process p = Runtime.getRuntime().exec(command);
- p.waitFor();
- BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
- BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
- tempfile.delete();
- String s = null;
- // read the output from the command
- System.out.println("Here is the standard output of the command:\n");
- while ((s = stdInput.readLine()) != null) {
- System.out.println(s);
- }
- // read any errors from the attempted command
- System.out.println("Here is the standard error of the command (if any):\n");
- while ((s = stdError.readLine()) != null) {
- System.out.println(s);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement