JavaMail send mail without using default port 25  
Author Message
Nicola Trevisan





PostPosted: 2004-6-2 16:51:00 Top

java-programmer, JavaMail send mail without using default port 25 Hi,
I must send email to a server that listen in port 2025,
how I can do it using JavaMail??

Thank to all.
Nicola Trevisan

PS: I insert my code so you can tell me where to place new code.....I hope

props = System.getProperties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "127.0.0.1");
session = Session.getDefaultInstance(props);
in = new FileInputStream(file);
msg = new MimeMessage(session, in);
msg.setFrom(new InternetAddress("email***@***.com"));
msg.setRecipient(Message.RecipientType.TO, new
InternetAddress("email***@***.com"));
transport = session.getTransport();
transport.send(msg);




 
Roedy Green





PostPosted: 2004-6-2 16:59:00 Top

java-programmer >> JavaMail send mail without using default port 25 On Wed, 02 Jun 2004 08:50:35 GMT, "Nicola Trevisan"
<email***@***.com> wrote or quoted :

>I must send email to a server that listen in port 2025,
>how I can do it using JavaMail??

Store store = session.getStore( receiveProtocol );
store.connect( receiveHost, receivePort, receiveLoginID,
receivePassword );


Transport transport = session.getTransport( sendProtocol );
transport.connect( sendHost, sendPort, sendLoginID, sendPassword );




--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Nicola Trevisan





PostPosted: 2004-6-2 17:17:00 Top

java-programmer >> JavaMail send mail without using default port 25 THANK YOU!!!!


 
 
Nicola Trevisan





PostPosted: 2004-6-2 17:36:00 Top

java-programmer >> JavaMail send mail without using default port 25 It doesn't work!!!
I try, but I have error like this:

javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: 127.0.0.1,
port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect

Can you give me a full code example???
I think I not open properly my session.

Thank
Nicola Trevisan


 
 
Yu SONG





PostPosted: 2004-6-2 17:53:00 Top

java-programmer >> JavaMail send mail without using default port 25 Nicola Trevisan wrote:
> It doesn't work!!!
> I try, but I have error like this:
>
> javax.mail.SendFailedException: Sending failed;
> nested exception is:
> javax.mail.MessagingException: Could not connect to SMTP host: 127.0.0.1,
> port: 25;
> nested exception is:
> java.net.ConnectException: Connection refused: connect
>
> Can you give me a full code example???
> I think I not open properly my session.
>
> Thank
> Nicola Trevisan
>
>

Have you installed a SMTP server listening on 127.0.0.1:25 ?


--
Song

More info.:
http://www.dcs.warwick.ac.uk/~esubbn/

 
 
Yu SONG





PostPosted: 2004-6-2 17:56:00 Top

java-programmer >> JavaMail send mail without using default port 25 Yu SONG wrote:
> Nicola Trevisan wrote:
>
>> It doesn't work!!!
>> I try, but I have error like this:
>>
>> javax.mail.SendFailedException: Sending failed;
>> nested exception is:
>> javax.mail.MessagingException: Could not connect to SMTP host:
>> 127.0.0.1,
>> port: 25;
>> nested exception is:
>> java.net.ConnectException: Connection refused: connect
>>
>> Can you give me a full code example???
>> I think I not open properly my session.
>>
>> Thank
>> Nicola Trevisan
>>
>>
>
> Have you installed a SMTP server listening on 127.0.0.1:25 ?
>
>
Sorry, I thought you want to connect to 25.

--
Song

More info.:
http://www.dcs.warwick.ac.uk/~esubbn/

 
 
Yu SONG





PostPosted: 2004-6-2 18:04:00 Top

java-programmer >> JavaMail send mail without using default port 25 Nicola Trevisan wrote:
> It doesn't work!!!
> I try, but I have error like this:
>
> javax.mail.SendFailedException: Sending failed;
> nested exception is:
> javax.mail.MessagingException: Could not connect to SMTP host: 127.0.0.1,
> port: 25;
> nested exception is:
> java.net.ConnectException: Connection refused: connect
>
> Can you give me a full code example???
> I think I not open properly my session.
>
> Thank
> Nicola Trevisan
>
>

try this,

props.put("mail.smtp.port", "2025");

--
Song

More info.:
http://www.dcs.warwick.ac.uk/~esubbn/

 
 
Jeeves





PostPosted: 2004-6-2 21:41:00 Top

java-programmer >> JavaMail send mail without using default port 25 "Nicola Trevisan" <email***@***.com> wrote in news:vxgvc.387717
$email***@***.com:

> Hi,
> I must send email to a server that listen in port 2025,
> how I can do it using JavaMail??

If you want to send email to a server that listens on a non standard
port you are out of luck. You can specify which port to connect to
for your *local* smtp relay (per the other replies), but if it is the
remote server that listens on a non-standard port it cannot be done
with Javamail.
 
 
Roedy Green





PostPosted: 2004-6-3 3:47:00 Top

java-programmer >> JavaMail send mail without using default port 25 On Wed, 02 Jun 2004 09:35:40 GMT, "Nicola Trevisan"
<email***@***.com> wrote or quoted :

> javax.mail.MessagingException: Could not connect to SMTP host: 127.0.0.1,

That does not sound like a very likely host. Do you have a mailserver
running locally?

About the only other trick is this.

Properties props = System.getProperties();
if ( CustConfig.needPasswordToSend )
{
props.setProperty ( "mail.smtp.auth", "true" );
}
// Get a Session object
session = Session.getDefaultInstance( props, null );


I do have complete working example, but the source is not free.
See http://mindprod.com/products.html#BULK

See http://mindprod.com/jgloss/javamail.html

and follow the link to the tutorial. The docs are impossible, but the
tutorial is fairly easy to follow.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
 
Roedy Green





PostPosted: 2004-6-3 3:49:00 Top

java-programmer >> JavaMail send mail without using default port 25 On Wed, 02 Jun 2004 13:41:00 GMT, Jeeves <email***@***.com> wrote or
quoted :

>If you want to send email to a server that listens on a non standard
>port you are out of luck. You can specify which port to connect to
>for your *local* smtp relay (per the other replies), but if it is the
>remote server that listens on a non-standard port it cannot be done
>with Javamail.

Why would it ignore your port specification?

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
 
Jeeves





PostPosted: 2004-6-3 5:38:00 Top

java-programmer >> JavaMail send mail without using default port 25 Roedy Green <email***@***.com> wrote in
news:email***@***.com:

> Why would it ignore your port specification?

It shouldn't, but with port 25 increasingly blocked by ISPs it is
conceivable that a server would listen on a non-standard port and
some 3rd party perform a redirect-type enhanced DNS service, for
example. I would add that my followup was only based on the poster
writing, "I must send email to a server that listen in port 2025" and
does not mention anything about their own relay. I just assumed
they're testing something out especially as the 127.0.0.1 address in
the exception is a dead giveaway they are not setting a local smtp
server. I think they they Javamail sends directly.

I would add to the original poster a potential hack: that they could
do an MX lookup on the domain they are sending do, enter that as
their mail host property, set the port property to 2025 and that
*should* work. Because it is inbound mail to that server the SMTP
transaction would be the same as your own relay sending it on.


 
 
Roedy Green





PostPosted: 2004-6-3 7:31:00 Top

java-programmer >> JavaMail send mail without using default port 25 On Wed, 02 Jun 2004 21:37:48 GMT, Jeeves <email***@***.com> wrote or
quoted :

>I would add to the original poster a potential hack: that they could
>do an MX lookup on the domain they are sending do, enter that as
>their mail host property, set the port property to 2025 and that
>*should* work. Because it is inbound mail to that server the SMTP
>transaction would be the same as your own relay sending it on.

However, you are now doing the work of the mailserver. If it is down,
you are supposed to try later. You are supposed to be able to send all
your mail to one server and have it distribute it.

Perhaps the practical way out is to have a local mailserver, or a
local proxy mailserver such as the one that comes with Zaep.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
 
Nicola Trevisan





PostPosted: 2004-6-3 15:23:00 Top

java-programmer >> JavaMail send mail without using default port 25 THANK TO ALL!!

I must describe you what I must to do. (and sorry for my english)

I must test some anti-spam product for my thesis.
Now I work in local and I have a Local MailServer and a program that is an
anti-spam SMTP.

I write a program like an "smtp stress", but I send a database of e-mail.
I must test what e-mail are view as spam and what as legal e-mail.

I take advantage from the situation to ask you if you know some anti-spam
program, to test it.
They must be anti-spam that work in SMTP so not for the home user.

I tell you thank again!!
Bye
Nicola Trevisan


 
 
Nicola Trevisan





PostPosted: 2004-6-3 15:42:00 Top

java-programmer >> JavaMail send mail without using default port 25 I try what tell me Yu SONG and it work!
Thank you Yu SONG, thank you very much.

I can't try to send the mail to another server....because I have only my PC.

Have a nice day!!!
Nicola