Example usage for org.apache.commons.mail Email setDebug

List of usage examples for org.apache.commons.mail Email setDebug

Introduction

In this page you can find the example usage for org.apache.commons.mail Email setDebug.

Prototype

public void setDebug(final boolean d) 

Source Link

Document

Setting to true will enable the display of debug information.

Usage

From source file:br.fgv.util.EmailSender.java

public static void enviarEmail(String body, String subject) throws EmailException {

    StringBuffer sb = new StringBuffer("");
    sb.append(body);/*from   w ww .  j  a  va2  s  . co  m*/

    Email email = new SimpleEmail();
    email.setHostName("smtp.gmail.com");

    email.setDebug(true);
    email.setSSLOnConnect(true);

    email.addTo("wesley.seidel@gmail.com");

    email.setAuthentication("wseidel.fgv", "batavinhofgv");

    email.setFrom("wseidel.fgv@gmail.com");
    email.setSubject(subject);
    email.setMsg(sb.toString());

    email.send();
}

From source file:gsn.utils.services.EmailService.java

/**
 * This method send a user configured email {@link org.apache.commons.mail.Email} after having updated the
 * email session from the property file.
 *
 * @param email//from  w w w.ja va2 s  . co m
 * @return true if the email has been sent successfully, false otherwise.
 * @throws org.apache.commons.mail.EmailException
 *
 */
public static void sendCustomEmail(org.apache.commons.mail.Email email) throws EmailException {
    email.setMailSession(Session.getInstance(Utils.loadProperties(SMTP_FILE)));
    email.setDebug(true);
    email.send();
}

From source file:edu.corgi.uco.sendEmails.java

public static void sendStudentSignUp(String studentFirstName, String studentLastName, Date time) {
    try {/*  w  w w.  j a  v  a 2 s  .c  o m*/
        System.out.print("hit send");
        Email email = new SimpleEmail();
        System.out.print("created email file");
        email.setDebug(true);
        email.setHostName("smtp.gmail.com");
        email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung"));
        email.setStartTLSEnabled(true);
        email.setSmtpPort(587);
        email.setFrom("ucocorgi@gmail.com", "UCO Advisement");
        email.setSubject("Advisement Update");
        email.setMsg("You have a new appointment with " + studentFirstName + " " + studentLastName + " on "
                + time + ". Any previously " + "scheduled appointments with them have been canceled.");

        System.out.print("Email Address: ucocorgi@gmail.com");
        email.addTo("ucocorgi@gmail.com");

        System.out.print("added values");

        email.send();
        System.out.print("sent");
    } catch (EmailException ex) {
        Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:edu.corgi.uco.sendEmails.java

public static void sendSecretaryNotification(String name) {
    try {//ww w. j ava2s.  c  o  m
        System.out.print("hit send");
        Email email = new SimpleEmail();
        System.out.print("created email file");
        email.setDebug(true);
        email.setHostName("smtp.gmail.com");
        email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung"));
        email.setStartTLSEnabled(true);
        email.setSmtpPort(587);
        email.setFrom("ucocorgi@gmail.com", "UCO Advisement");
        email.setSubject("Advisement");
        email.setMsg(name + "'s Schedule has been approved. "
                + "Please remove their hold promptly so they may enroll.");

        System.out.print("Email Address: ucocorgi@gmail.com");
        email.addTo("ucocorgi@gmail.com");

        System.out.print("added values");

        email.send();
        System.out.print("sent");
    } catch (EmailException ex) {
        Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:edu.corgi.uco.sendEmails.java

public static void sendAdvisorCancel(String emailAddress, String studentFirstName, String studentLastName) {
    try {//w ww  .  j ava2s.  co m
        System.out.print("hit send");
        Email email = new SimpleEmail();
        System.out.print("created email file");
        email.setDebug(true);
        email.setHostName("smtp.gmail.com");
        email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung"));
        email.setStartTLSEnabled(true);
        email.setSmtpPort(587);
        email.setFrom("ucocorgi@gmail.com", "UCO CS Corgi");
        email.setSubject("Advisement Update");
        email.setMsg(
                studentFirstName + " " + studentLastName + "your appointment has been canceled by the advisor."
                        + "You will need to log in to CORGI and sign up for another appointment to get advised."
                        + "Thank you.");
        System.out.print("Email Address: " + emailAddress);
        email.addTo(emailAddress);

        System.out.print("added values");

        email.send();
        System.out.print("sent");
    } catch (EmailException ex) {
        Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:edu.corgi.uco.sendEmails.java

public static void sendStudentConfirmation(String fn, String ln, Date date, String email2) {

    try {/* w w w.j a va  2 s .  c  om*/
        System.out.print("hit send");
        Email email = new SimpleEmail();
        System.out.print("created email file");
        email.setDebug(true);
        email.setHostName("smtp.gmail.com");
        email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung"));
        email.setStartTLSEnabled(true);
        email.setSmtpPort(587);
        email.setFrom("ucocorgi@gmail.com", "UCO Advisement");
        email.setSubject("Advisement Update");
        email.setMsg(fn + " " + ln + ", you have signed up for an advisement appointment at " + date
                + ". It is recommended that you use the Corgi system to define your "
                + "preferred schedule for next semester prior to your meeting.");

        System.out.print("Email Address: ucocorgi@gmail.com");
        email.addTo(email2);

        System.out.print("added values");

        email.send();
        System.out.print("sent");
    } catch (EmailException ex) {
        Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Control.CommonsMail.java

/**
 * Classe que envia E-amil//from ww  w .j  a  v a 2  s .  com
 * @throws EmailException
 */
public void enviaEmailSimples(String Msg) throws EmailException {

    Email email = new SimpleEmail();
    email.setDebug(true);
    email.setHostName("smtp.gmail.com"); // o servidor SMTP para envio do e-mail
    //email.setHostName("smtp.pharmapele.com.br"); // o servidor SMTP para envio do e-mail
    email.setSmtpPort(587);
    email.setSSLOnConnect(true);
    email.setStartTLSEnabled(true);
    email.setAuthentication("softwaredeveloperantony@gmail.com", "tony#020567");
    //email.setAuthentication("antony@pharmapele.com.br", "tony#020567");

    //email.setFrom("softwaredeveloperantony@gmail.com"); // remetente
    email.setFrom("antony@pharmapele.com.br"); // remetente
    email.setSubject("Exporta Estoque lojas"); // assunto do e-mail
    email.setMsg(Msg); //conteudo do e-mail
    email.addTo("antony@pharmapele.com.br", "Antony"); //destinatrio

    //email.sets(true);
    //email.setTLS(true);
    try {

        email.send();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.packtpub.e4.advanced.event.mailman.MailSender.java

@Override
public void handleEvent(Event event) {
    String topic = event.getTopic();
    if (topic.startsWith("smtp/")) {
        String importance = topic.substring("smtp/".length());
        String to = (String) event.getProperty("To");
        String from = (String) event.getProperty("From");
        String subject = (String) event.getProperty("Subject");
        String body = (String) event.getProperty("DATA");
        try {/*w  w  w .  j a  va 2s  .c  o m*/
            Email email = new SimpleEmail();
            email.setDebug(false);
            email.setHostName(hostname);
            email.setSmtpPort(port);
            email.setFrom(from);
            email.addTo(to);
            email.setSubject(subject);
            email.setMsg(body);
            email.addHeader("Importance", importance);
            email.send();
            log(LogService.LOG_INFO, "Message sent successfully to " + to);
        } catch (EmailException e) {
            log(LogService.LOG_ERROR, "Error occurred" + e);
        }
    }
}

From source file:com.basetechnology.s0.agentserver.mail.AgentMail.java

public int sendMessage(User user, String toEmail, String toName, String subject, String message,
        String messageTrailer1, String messageTrailer2) throws AgentServerException {
    try {//w  ww .ja v  a 2  s  . c o m
        // Wait until we have mail access
        agentServer.mailAccessManager.wait(user, toEmail);

        int messageId = ++nextMessageId;
        log.info("Sending mail on behalf of user " + user.id + " with message Id " + messageId + " To: '<"
                + toName + ">" + toEmail + "' Subject: '" + subject + "'");

        Email email = new SimpleEmail();
        email.setDebug(debug);
        email.setHostName(mailServerHostName);
        email.setSmtpPort(mailServerPort);
        email.setAuthenticator(new DefaultAuthenticator(mailServerUserName, mailServerUserPassword));
        email.setTLS(true);
        email.setFrom(mailServerFromEmail, mailServerFromName);
        // TODO: Reconsider whether we want to always mess with subject line
        email.setSubject(subject + " (#" + messageId + ")");
        email.setMsg(message + messageTrailer1 + (messageTrailer2 != null ? messageId + messageTrailer2 : ""));
        email.addTo(toEmail, toName);
        email.send();
        log.info("Message sent");

        // Return the message Id
        return messageId;
    } catch (EmailException e) {
        e.printStackTrace();
        throw new AgentServerException("EmailException sending email - " + e.getMessage());
    }
}

From source file:com.kylinolap.job.tools.MailService.java

public void sendMail(List<String> receivers, String subject, String content) throws IOException {

    Email email = new HtmlEmail();
    email.setHostName(host);//w  ww .ja  v a 2 s . c  o m
    email.setDebug(true);
    try {
        for (String receiver : receivers) {
            email.addTo(receiver);
        }

        email.setFrom(sender);
        email.setSubject(subject);
        email.setCharset("UTF-8");
        ((HtmlEmail) email).setHtmlMsg(content);
        email.send();
        email.getMailSession();

        System.out.println("!!");
    } catch (EmailException e) {
        e.printStackTrace();
    }
}