mails not going outside intranet network

15 views
Skip to first unread message

Garima

unread,
Apr 15, 2010, 2:41:15 AM4/15/10
to Java Email Server
I have downloaded JES plugin for eclipse.I am able to send mails
within company network but when I am sending mails to outside network
like gmail,rediffmail,hotmail account then its not going.I dont see
any error or exception when I send mail to outside network and see
message as Sucessfully Sent mail to All Users.Kindly help me.

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");
}
}

koolankit.mzn

unread,
Apr 15, 2010, 11:53:40 AM4/15/10
to Java Email Server
hello garima...
i think you left out to configure the relay address option here is how
to do tht...
check the following setting in mail.conf ....

# 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.........

Reply all
Reply to author
Forward
0 new messages