My program is :
package com.mycompany.servlet;
import javax.mail.*;
import javax.mail.internet.*;
import java.security.Security;
import java.util.*;
import java.io.*;
public class TestMail {
public void postMail() throws MessagingException{
Properties props = System.getProperties();
props.put("mail.smtp.host", "localhost");
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.starttls.enable", "false");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");
// fill props with any information
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("te...@localhost.com"));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress("kap...@gmail.com"));
message.setContent("Hello", "text/plain");
message.setSubject("First Mail");
message.setText("Welcome to JavaMail");
Transport.send(message);
}
public static void main(String args[]) throws Exception
{
TestMail testMail = new TestMail();
testMail.postMail();
System.out.println("Sucessfully Sent mail to All Users");
}
}
# Individual IP addresses can be specified to allow email to be
relayed.
# This can be useful if you want to provide access to specific
machines or
# sets of machines, including your localhost. Wildcards can be used
# to specify a range of addresses.
# ex: 192.168.*.* allows all addresses that start with 192.168 to
# relay email. Partial wildcards are not allowed. ex: 19*.168.0.1 is
invalid.
# Multiple addresses can be specified as a comma separated list.
relay.ipaddresses=127.0.0.1
pls put 127.0.0.1 or any other ip similiar to 127.*.*.* in
relay.ipaddress
and the same when u send mail
instead of
props.put("mail.smtp.host", "localhost");
use
props.put("mail.smtp.host", "127.0.0.1");
if u use repaly.ipaddress=127.0.0.1
it will definitely work
try it..
n thn reply me.........