Sending Mail from JSP-Servlet
hi all,
Can any one help me, how can i send the mail from JSP-Servlet.
in Spring, we have a the following package to send mail,
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
Suggest me to solve the problem.
Thanx in advance.
Bala
Hi balu,
i already go thru that API. My problem is if i add any additional jar file for sending the mail from JSP or Servlets only. not in high technology.
i mention spring as an example.
so, kindly suggets me on that.
Bala
Similar Messages
-
Need to Send Mail from JSP...
Dear Team,
I Need to Send Mail from JSP, have Designed user Interface to enter
to, from, subject, and message text .
Have Downloaded mail.jar and activate.jar file..... and placed in tomcat lib directory and WEBAPPS/WEB-INF/lib Directory too
How do i send a mail to user ?
do I require something else apart from things that i have mentioned?
do i have to Configure SMTP, POP3 or Something like this....
Now If I Create a object of Type MimeMessage and Set Recipient, from, subject and if i say transport.send(message) will this do My JOB???Dear Team,
I Need to Send Mail from JSP, have Designed user
Interface to enter
to, from, subject, and message text .
Have Downloaded mail.jar and activate.jar file.....
and placed in tomcat lib directory and
d WEBAPPS/WEB-INF/lib Directory too
How do i send a mail to user ?
do I require something else apart from things that i
have mentioned?
do i have to Configure SMTP, POP3 or Something like
this....
Now If I Create a object of Type MimeMessage and Set
Recipient, from, subject and if i say
transport.send(message) will this do My JOB???Yup! in addition to all the above i need to know my mail box outgoing mail server. and that's enough...... i am able to do that.
Regards,
Jagadeesh HS. -
hi,
i want to send mail from my jsp page.
1) how can i do this
2) do i need any mail server for doin this
thanks
regards
manoji want to send mail from my jsp page.
1) how can i do this
2) do i need any mail server for doin thisRead
http://java.sun.com/developer/onlineTraining/JavaMail/
Rather,
try this:
http://jakarta.apache.org/taglibs/doc/mailer-doc/mailer-1.1/index.html -
Hi guys,
can anyone help me out of this problem ??
I have written a piece of code which sends mail from a jsp page.
When I use the 'Recipient'(TO) as an address in the same domain
(ie,<xxx>@<apeejaygroup.com>) it works fine.
But when I use an address such as <xxx>@<rediffmail.com>
the code gives an error like -
"javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 550 5.7.1 ... Relaying denied"
I am sending the piece of code for reference..
String host ="192.168.33.11";
String from="[email protected]";
String to="<xxx>@apeejaygroup.com";
( HERE USING THE ADDRESS AS <xxx>@<rediffmail>.com
GIVES THE EXCEPTION - javax.mail.SendFailedException: 550 5.7.1 ... Relaying denied )
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
javax.mail.Session session1 = javax.mail.Session.getDefaultInstance
(props, null);
MimeMessage message = new MimeMessage(session1);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Your Registration Details");
message.setContent(body,"text/html");
Transport.send(message);
Please help me out of this.
Regards
Satrajitas you said that it might require authentication
but our mail server doesn't require authentication to mail.
Now what should i do ??Many servers are now authenticating by requiring you to fetch your e-mail before sending. This is basically because most SMTP mail servers CAN NOT authenticate in the normal sense of the word. So, they use the fetch process for authentication. The fetch process already requires authentication normally. Then your IP address will be good for, say, 20 minutes, and you can relay e-mail through the server.
It works with most E-mail clients such as Outlook or Netscape, because the default behavior is to 1.Connect to the POP server, 2.Login, 3.Download any new mail, 4.Connect to the SMTP server, 5.Upload any mail to send.
Even if you don't have any mail, your IP address will at least have been authenticated. Even if you just check for mail, and not download any, you should be OK.
So what I'd suggest is that you write some code that attempts to connect to your mail system's POP server, get authenticated successfully, then try sending out the e-mail through the SMTP server. -
Hi everyone, I was trying to send a mail from the servlet program. I have included the following packages..
{color:#000080}import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.event.*;
import java.util.*;{color}
But the code is not compiling,am getting the folowing compilation errors.
F{color:#ff0000}:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Arun\WEB-INF\clas
ses>javac PasswordMailerServlet.java
PasswordMailerServlet.java:5: package javax.mail does not exist
import javax.mail.*;
^
PasswordMailerServlet.java:6: package javax.mail.internet does not exist
import javax.mail.internet.*; // important
^
PasswordMailerServlet.java:7: package javax.mail.event does not exist
import javax.mail.event.*; // important
^
PasswordMailerServlet.java:33: cannot find symbol
symbol : class Session
location: class PasswordMailerServlet
Session session1 = Session.getDefaultInstance(props,null);
^
PasswordMailerServlet.java:33: cannot find symbol
symbol : variable Session
location: class PasswordMailerServlet
Session session1 = Session.getDefaultInstance(props,null);
^
PasswordMailerServlet.java:43: cannot find symbol
symbol : class Message
location: class PasswordMailerServlet
Message message =new MimeMessage(session1);
^
PasswordMailerServlet.java:43: cannot find symbol
symbol : class MimeMessage
location: class PasswordMailerServlet
Message message =new MimeMessage(session1);
^
PasswordMailerServlet.java:45: cannot find symbol
symbol : class InternetAddress
location: class PasswordMailerServlet
message.setFrom(new InternetAddress(s1));
^
PasswordMailerServlet.java:47: package Message does not exist
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(s2,fa
lse));
^
PasswordMailerServlet.java:47: cannot find symbol
symbol : variable InternetAddress
location: class PasswordMailerServlet
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(s2,fa
lse));
^
PasswordMailerServlet.java:53: cannot find symbol
symbol : variable Transport
location: class PasswordMailerServlet
Transport.send(message);
^
11 errors
{color}
{color:#000000}Please give me a solution!{color}
Edited by: Arun_ece on Feb 16, 2009 8:16 PMHi, thank you. I already mentioned the path,like this(F:/Sun/lib)..
but i didnt specifically inlcuded the jar files like this(F:/Sun/lib/mail,jar)..
now it is working!
Cheers!! -
Sending mail from JSP through Microsoft Outlook
Hi all,
i want to send an e-mail from JSP by clicking on link or button through Microsoft's Outlook..
Can anyone guide me..something like this,
try{
props = new Properties();
props.load(this.getClass().getClassLoader().getResourceAsStream("contact.properties"));
int i=0;
String referer = props.getProperty("contact.allow.referer."+i);
email = props.getProperty("report.email.error");
while(referer != null){
i++;
contact.put(referer, "true");
referer = props.getProperty("contact.allow.referer."+i);
}catch(Exception e){
e.printStackTrace();
try{
Session session = (Session)new InitialContext().lookup(this.props.getProperty("reports.jndi.email"));
SMTPMessage m = new SMTPMessage(session);
m.setFrom(InternetAddress.parse(this.props.getProperty("report.email.from"))[0]);
m.setRecipient(RecipientType.TO, new InternetAddress(this.email));
m.setSubject(this.getSub());
StringBuffer msg = new StringBuffer();
msg.append("Employee Name: "+fn + " " + ln +"\n");
msg.append("Employee ID: "+this.getId()+"\n");
msg.append("Message: "+this.getMsg()+"\n");
m.setText(msg.toString());
m.setReplyTo(InternetAddress.parse("no-reply"));
m.saveChanges();
Transport trans = session.getTransport();
trans.send(m);
trans.close();
}catch(Exception e){
e.printStackTrace();
} contact.properties:
reports.jndi.email=java:comp/env/globalMail
report.generation.timeout=3000
report.email.subject=Some Subject
[email protected]
[email protected] -
Sending mail from JSP page with attachment
I have a requirement to send mail with attachment from my jsp pages, which should come to a particular mail box. Can any one help me by sending sample codes. Thankx in advance.
hi,
When request is posted you have to save file data from request to a file. you can not access the data using request.getParameter("file"). -
Hello,
can some one help me to send emails from a jsp page.
and if possible the source code of jsp or java...
Thanks !read this:
http://www.jspinsider.com/tutorials/jsp/javamail/jspjavamail_1.view -
HI Everyone,
Please help me out in this. It is very urgent so not able search the same in this forum.
I have a J2EE application. The view is in JSP. If i click a button from a JSP page, any mail client (Microsoft Outlook) has to open and current page need to be attached as html. THen user wish to send the mail to somebody...
So my aim is to open a outlook and attache the current JSP page as html. PLease help me out !Instead of outlook, you can do it easily using SMTP
-
How to send mail from jsp pageq
Pls help me with this topic
Thanks alotCan you make it clearer. Pls give me a sample code if possible
Thanks alot -
Can we run external mail program from JSP / Servlet deployed on tomcat
Hi folks,
Had a tough time getting JavaMail API to work, finally when things seem to be working
there were some issues with the vendor's server, so finally gave up the idea.
On the server Apache and Tomcat are integrated via mod_jk and currently I redirect to a php page
which acts as a helper to send mail, however for the given business needs and server's limitations
there are potential security holes.
So I was wondering if I could directly execute the linux sendmail program from JSP/Servlet
as we would in a standalone java program or do we need special settings on Tomcat to execute external
programs.
Please let me know your views / ideas / comments on this
Thanks in advance
AbishekHi
It's not designed for you to be able to do this, it needs to run through 10gAS or 11gWeblogic.
Tony -
How to send mail from servlets
m having troubles sending mail from servlets...
how do you use the SimpleMailUser object needed in the session?
a sample code on this would be of great help, thanks!<html>
<body bgcolor="white">
<font size=5 color="black">
<%@ page import="javax.servlet.http.HttpUtils" %>
<%@ page import="java.util.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.io.*" %>
<%@ page import= "sun.net.smtp.SmtpClient" %>
<%
String from,to,subject,msgbody,serverName;
try
from = request.getParameterValues("from")[0];
to = request.getParameterValues("to")[0];
subject = request.getParameterValues("subject")[0];
msgbody = request.getParameterValues("msgbody")[0];
serverName = request.getParameterValues("server")[0];
catch (Exception e) // Generally Speaking, an Error getting one of these
// Values means that it wasnt passed in; inform the user
out.println("You must call this JSP from this ");
out.println("<A href=\"FormMail.htm\"> form</A>.<BR>");
out.flush();return;
%>
Hold On A Moment while I try to Send Your Mail... <BR>
<%
out.flush();
// Here are the real guts of the mail sending
try
sun.net.smtp.SmtpClient sm = new sun.net.smtp.SmtpClient(serverName);
sm.from(from);
sm.to(to);
PrintStream msg = sm.startMessage();
msg.println("To: "); // Note dont use + for Performance
msg.println(to);
msg.println("Subject: ");
msg.println(subject);
msg.println();
msg.println(msgbody);
msg.println("==============");
msg.print("This mail brought to you by JSP MAIL..from a user at IP ");
msg.println(request.getRemoteHost());
sm.closeServer();
out.println("Your Mail Has Been Sent!");
catch (Exception e)
out.println("The mail couldn't be sent, probably because the mailhost wasnt set correctly.<BR> ");
out.println("The error message I am getting is: ");
out.println(e.getMessage());
%>
<BR>
<BR>
Click here to send another! -
I want to send email from jsp,
i want to send email from jsp, i dont know smtp:host, how to send mail?
plz carify this doubt sir.OK thanks sir but i installed alredy. i write this code. plz send any error's are there. and i dont know smtp:host name. i put my port address?
try{
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "//10/0/6/252");
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
msg.setFrom(new InternetAddress("[email protected]"));
msg.addRecipient(Message.RecipientType.To,new InternetAddress("[email protected]"));
// Setting the Subject and Content Type
msg.setSubject("hi..");
msg.setText("hi bharath how are you");
Transport.send(msg);
catch(Exception e)
out.println(e);
} -
How to send mail using jsp program
am very new to jsp and doing my final year project. i need to send mails using my jsp program.can anyone say wht to do that is wht to include to send mails using jsp program. n also a sample code to send mail using jsp program.
Thanx in advanceUse below script.
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "mailserver.com");
Session s = Session.getInstance(props,null);
InternetAddress from = new InternetAddress("[email protected]");
InternetAddress to = new InternetAddress([email protected]");
MimeMessage message = new MimeMessage(s);
message.setFrom(from);
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Your subject");
message.setText("Your text");
Transport.send(message);
%>{code} -
Hi,
I am newbee in Java, I want to send mail to different accounts using java from my website. Plz help me with working example. I am new to java.
Thanks in advance,
devomThanks, but I want to send mail from my WEb page that is in JSP. The arcticle pointed out sends mail in core java. I already know how to send in Core java, but i want to send through JSP. Plz help me.
Thanks in advance,
Devom
Maybe you are looking for
-
Importing os Open PO,GRPO and Invoice Through DTW
Hi All, Please tell me what are the exact Templates and Mandatory fields for Open PO,GRPO and Invoice through DTW. Kind Regards silpa
-
URGENT!! How to avoid paint all the components?
In the following code sample, when you move the mouse, the top-level JPanel (with the name p) repaints itself with a red circle. The strange thing is that also the 4 JButtons repaint themselves!! (this is shown by the System.out). If the container of
-
Mac OSX 10.6 cannot be installed on this computer
Hi everybody - this is my first post on here so please be gentle! My kit: 13" MBP, Intel core 2 duo @ 2.26GHz. 2MB DDR3 RAM. Current OS 10.5.8 I've been getting the "Mac OSX 10.6 cannot be installed on this computer" error message repeatedly whenever
-
Dynamically resizing a JPanel when drawing
Hi guys, Well, what I want to do is draw a train on a JPanel. its working perfectly. And I have a Scroller on it. The JPanel is STARTING_HEIGHT & STARTING_WIDTH at the begining. But, I want a check which will increase the size of the Panel if the tra
-
Help With SCSM 2012 R2 New Setup
Hi, I'm new to SCSM and planning on setting up SCSM in our environment. I've got 2 Windows 2012 Servers stood up for me. I've seen the step by step tutorials and all but have a couple questions. So on my first server "SCSM" should I install SQL 2012