Java Mail - How to run the program
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kandaswami_k
Posted On:   Wednesday, August 10, 2005 08:58 AM

This is the program given in sun’s site for sending mail : import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class MailExample { public static void main (String args[]) throws Exception { String host = args[0]; String from = args[1]; String to = args[2]; // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", host); // Get session Session session = Session.getDefaultInstance(props, null); // Define message MimeMessage message = new MimeMessage(session); // Set the from address    More>>

This is the program given in sun’s site for sending mail :

			
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class MailExample {
public static void main (String args[]) throws Exception {
String host = args[0];
String from = args[1];
String to = args[2];

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", host);

// Get session
Session session = Session.getDefaultInstance(props, null);

// Define message
MimeMessage message = new MimeMessage(session);

// Set the from address
message.setFrom(new InternetAddress(from));

// Set the to address
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));

// Set the subject
message.setSubject("Hello JavaMail");

// Set the content
message.setText("Welcome to JavaMail");

// Send message
Transport.send(message);
}
}




To Run this program from prompt we need to give as :

java MailExample SMTP.Server from@address to@address

the problem is here, I don’t have any SMTP.Server running on my system But I have access to internet.



Is it possible to send mail from say: kanda@yahoo.com to swamy@hotmail.com by running this program MailExample.java



If it is possible tell me how to achieve it. Is there an free SMTP service providers through which I can send mail between these two email addresses.    <<Less

Re: Java Mail - How to run the program

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, August 10, 2005 08:02 PM

In the good old days before spammers, there were plenty of open SMTP relay servers everywhere. (until the mid to late 1990's)



Now you'll have to sign up with an ISP so they can cut you off quickly if you are a spammer (or, more likely, if your account is hijacked by spammers).
About | Sitemap | Contact