Results 1 to 2 of 2
- 03-24-2009, 09:21 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
Facing problem while sending e-mail
my code runs on a windows server on my machine but as i upload the same class file to the linux machine it does not work.
As there is no error generation go cant get the exact problem..
See my code below if u could help me...
public static String myemail = "xyz@abc.com", //username
mypassword = "*************", //password
myhost = "smtp.abc.com", // smtp address
myport = "234", // port address
mysubject = "Hello",
mytext = "this is just a test mail";
public String mail(String recp)
{
Properties pro = new Properties();
pro.put("mail.smtp.user", myemail);
pro.put("mail.smtp.host", myhost);
pro.put("mail.smtp.port", myport);
pro.put("mail.smtp.starttls.enable","true");
pro.put("mail.smtp.auth", "true");
pro.put("mail.smtp.debug", "true");
pro.put("mail.smtp.socketFactory.port",myport);
SecurityManager security = System.getSecurityManager();
try
{
Authenticator authen = new SMTPConfig();
Session session = Session.getInstance(pro, authen);
session.setDebug(true);
MimeMessage msg = new MimeMessage(session);
msg.setText(mytext);
msg.setSubject(mysubject);
msg.setFrom(new InternetAddress(myemail));
msg.addRecipient(Message.RecipientType.TO, new
InternetAddress(recp));
Transport.send(msg);
}
catch (Exception ex)
{
ex.printStackTrace();
}
return null;
}
private class SMTPConfig extends javax.mail.Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(myemail, mypassword);
}
}
- 03-25-2009, 07:34 AM #2
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
Sending a Mail
By haiforhussain in forum Advanced JavaReplies: 7Last Post: 07-30-2008, 12:28 AM -
Java mail problem Urgent
By sundarjothi in forum Advanced JavaReplies: 0Last Post: 06-02-2008, 11:34 AM -
Sending Mail Using Sockets
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:05 PM -
Sending a mail with the local mail program
By thedude in forum Advanced JavaReplies: 2Last Post: 07-23-2007, 12:19 PM -
Sending mail Using JAVAMAIL
By peiceonly in forum Advanced JavaReplies: 3Last Post: 07-19-2007, 02:11 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks