Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java API
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other JSE/JEE APIs
working example for sending mail from behind the proxy
Abhi Yadav
Greenhorn
Posts: 6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Has any body over there ever sent a mail from behind the proxy using the
java
API, i am fed up with trying different permutations and combinations,
pls send the code, that u hv already tested for work
Thanks a lot
import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class SendMail { public static void main(String[] args) { Properties props = System.getProperties(); // Define SMTP host props.put("mail.smtp.host", "mail.yahoo.com"); props.put("username",""); props.put("password",""); props.put("proxySet", "true"); props.put("proxyHost", "IPADDRESS"); props.put("proxyPort", "PORTNO"); try { // Get a session Session session = Session.getDefaultInstance(props, null); // Create a new MimeMessage message = new MimeMessage(session); // Populate message.setText("Hello from first JavaMail message"); message.setSubject("Hi!"); message.setFrom(new InternetAddress("abhi_1681@yahoo.co.in")); message.addRecipient( Message.RecipientType.TO, new InternetAddress("abhi_yadav@india.com")); // Send the message Transport.send(message); } catch (MessagingException me) { System.err.println(me.getMessage()); } System.out.println("Message Sent"); } }
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JavaMail, servlet error
javax.mail package
isMailSent()
Help me to run my first JavaMail app
Java Mail Authentication
More...