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
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Other JSE/JEE APIs
Mail not working
Joseph Smithern
Ranch Hand
Posts: 89
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am trying to get a mail page to work but it doesnt send anything.
Please advise what I am doing wrong. My mail server smtp address is correct.
<%@ page import="javax.mail.*, javax.mail.internet.*,java.util.*;"> <% try { String to = "jones@company.com"; String from = "smith@company.com"; String subject = "Send Java Mail"; String body = "Message from java mail"; Properties props = System.getProperties(); props.put("mail.smtp.host", 123.15.191.44); Session session = Session.getDefaultInstance(props, null); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false)); msg.setSubject(subject); msg.setText(body); // -- Send the message -- Transport.send(msg); System.out.println("Message sent OK."); } catch (Exception ex) { ex.printStackTrace(); } %>
[ March 05, 2007: Message edited by: Joseph Smithern ]
Ulf Dittmer
Rancher
Posts: 43081
77
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Are there any exception in the log files?
As a aside, I would advise to do
Java
coding like this in a
servlet
or a backing bean, not in a
JSP
.
a wee bit from the empire
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Email from with name of person
Email with jsp
timed out exception while sending mail to my yahoo account
Email in jsp
JSP using javamail
More...