Ejemplo n.º 1
0
 protected DCServerFactory.ResultCode sendEmail(
     String frEmail, String toEmail, String subj, String body) {
   if (StringTools.isBlank(frEmail)) {
     Print.logError("'From' Email address not specified");
     return DCServerFactory.ResultCode.TRANSMIT_FAIL;
   } else if (StringTools.isBlank(toEmail) || !CommandPacketHandler.validateAddress(toEmail)) {
     Print.logError("'To' SMS Email address invalid, or not specified");
     return DCServerFactory.ResultCode.TRANSMIT_FAIL;
   } else if (StringTools.isBlank(subj) && StringTools.isBlank(body)) {
     Print.logError("Command string not specified");
     return DCServerFactory.ResultCode.INVALID_ARG;
   } else {
     try {
       Print.logInfo("SMS email: to <" + toEmail + ">");
       Print.logDebug("  From   : " + frEmail);
       Print.logDebug("  To     : " + toEmail);
       Print.logDebug("  Subject: " + subj);
       Print.logDebug("  Message: " + body);
       SendMail.send(frEmail, toEmail, null, null, subj, body, null);
       return DCServerFactory.ResultCode.SUCCESS;
     } catch (Throwable t) { // NoClassDefFoundException, ClassNotFoundException
       // this will fail if JavaMail support for SendMail is not available.
       Print.logWarn("SendMail error: " + t);
       return DCServerFactory.ResultCode.TRANSMIT_FAIL;
     }
   }
 }
Ejemplo n.º 2
0
 /* send an email  with attachment */
 public static boolean send(
     String from,
     String to,
     String cc,
     String bcc,
     String subject,
     String msgBody,
     SendMail.SmtpProperties smtpProps,
     SendMail.Attachment attach) {
   try {
     return SendMail.send(from, to, cc, bcc, subject, msgBody, attach, smtpProps);
   } catch (Throwable t) { // NoClassDefFoundException, ClassNotFoundException
     // this will fail if JavaMail support for SendMail is not available.
     Print.logWarn("SendMail error: " + t);
     return false;
   }
 }