Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

JSP send mail script not working.

Discussion in 'E-mail Discussion' started by mak_the_admin, Dec 17, 2007.

  1. mak_the_admin

    mak_the_admin Member

    Aug 10, 2007
    Likes Received:
    Trophy Points:

    my client have Java source at domain, but till now
    can't send email

    On local pc the source running well but after upload to server, the
    source can't work

    sample source below please review the source

    If you have sample Java source that running well on your server please
    send to me

    Below is the script.

    -------- Source java :
    package package;

    import javax.mail.*;
    import javax.mail.internet.*;
    //import javax.activation.*;

    import org.apache.commons.mail.DefaultAuthenticator;

    // lib : activasion.jar
    // mail.jar

    public class SendApp {
    public static void send(String smtpHost, int smtpPort, String from,
    String to, String subject, String content)
    throws AddressException,
    MessagingException {
    // Create a mail session
    java.util.Properties props = new java.util.Properties();
    props.put("", smtpHost);
    props.put("mail.smtp.port", "" + smtpPort);

    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");

    String user = "user";
    String pass = "";
    // password same with cpanel pass

    Authenticator auth = new DefaultAuthenticator(user, pass);
    Session session = Session.getDefaultInstance(props, auth);

    // Construct the message
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    msg.setRecipient(Message.RecipientType.TO, new

    // Send the message

    public static void main(String[] args) throws Exception {
    // Send a test message
    send("", 25, "",
    "", "Subject:
    TestSubject", "TestText");

    Please provide solution if any ASAP.

    Thank you.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice