Results 1 to 2 of 2
- 12-27-2007, 12:00 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 1
- Rep Power
- 0
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.
- 05-27-2008, 06:37 AM #2
Member
- Join Date
- Apr 2008
- Location
- villupuram
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
A Client to Send SMTP Mail
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:06 PM -
Retreiving of mail body using mail number
By chandu.v09 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-13-2008, 02:25 PM -
Sample ANT Script
By Java Tip in forum Java TipReplies: 0Last Post: 01-24-2008, 03:22 PM -
Send a pic through mail, in java
By lenny in forum Advanced JavaReplies: 1Last Post: 07-25-2007, 02:49 PM -
Sending a mail with the local mail program
By thedude in forum Advanced JavaReplies: 2Last Post: 07-23-2007, 12:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks