Results 1 to 2 of 2
  1. #1
    profuse is offline Member
    Join Date
    Dec 2007
    Posts
    1
    Rep Power
    0

    Default JSP send mail script not working.

    Hello,

    my client have Java source at domain domain.com, 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 java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    //import javax.activation.*;

    import org.apache.commons.mail.DefaultAuthenticator;

    // lib : activasion.jar
    // mail.jar
    // commons.email-1.0.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("mail.smtp.host", 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
    InternetAddress(to));
    msg.setSubject(subject);
    msg.setText(content);

    // Send the message
    Transport.send(msg);
    }

    public static void main(String[] args) throws Exception {
    // Send a test message
    send("domain.com", 25, "user@domain.com",
    "user@domain.com", "Subject:
    TestSubject", "TestText");
    System.out.println("finish");
    }
    }
    ================================================== ===============

    Please provide solution if any ASAP.

    Thank you.

  2. #2
    sundarjothi is offline Member
    Join Date
    Apr 2008
    Location
    villupuram
    Posts
    22
    Rep Power
    0

Similar Threads

  1. A Client to Send SMTP Mail
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 09:06 PM
  2. Retreiving of mail body using mail number
    By chandu.v09 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-13-2008, 03:25 PM
  3. Sample ANT Script
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 04:22 PM
  4. Send a pic through mail, in java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 03:49 PM
  5. Sending a mail with the local mail program
    By thedude in forum Advanced Java
    Replies: 2
    Last Post: 07-23-2007, 01:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •