Help: sending email from JSP or MSB problem

Hi Everyone,
I have an J2EE application which sends email to a user when a user submit a form. The email is send from Jsp page and MSD using sun.net.smtp.SmtpClient class. The codes for sending email are:
String to = "[email protected]";
String from="[email protected]";
String smtpHost="the mail smtp host";
SmtpClient client = new SmtpClient(smtpHost);
client.from(from);
client.to(to);
PrintStream message = client.startMessage();
message.println("To: " + to);
message.println("Subject: a subject");
message.println("email body");      
It sends email to internal email account user without a problem. However, when the email reciever's email address is a outside email account such as yahoo, I got the following error message:
Error 500: 550 not local host yahoo.com, not a gateway                     
This email sending system worked ok before for outsider email address in our old email server. We recerently switched to a new email server. The jsp page and MDB can no longer send email to outside account.
Any help is appreciated.
thanks

Please see this section in The J2EE 1.4 Tutorial for an example of sending email from an enterprise bean:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Resources5.html#wp79827

Similar Messages

  • 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);
         }

  • Send Email From JSP.

    Hai,
    I am new to JSP.Now I create one application in jsp using netbean5.I need code for send a email from that application.
    please any one help to me
    by
    Beemaraj.v

    You can use the JavaMail API for that.
    JavaMail homepage: http://java.sun.com/products/javamail
    JavaMail FAQ: http://java.sun.com/products/javamail/FAQ.html
    JavaMail subforum here: http://forum.java.sun.com/forum.jspa?forumID=43

  • JavaMail - Sending Email from JSP Templates

    Is there any existing method of sending emails (I'm using JavaMail) from templates written as JSP files? I've done quite a bit of Googling on the matter, and I'm still a bit new to JSP.
    The solution I'm looking for is a way to have an HTML template for an email with variables embedded, which are to be replaced by data from the servlet.
    I know numerous individuals have run in to a similar situations, so I'm sure a solution exists.

    The content of an email can come from a "DataSource"
    There is an implementation of Datasource that can download from a URL (javax.activation.URLDataSource)
    That means you can write a JSP which will be your "email" and then call that JSP to generate the email text.

  • How can Send Email From JSP to all Mail server.it gives error

    I try this code in netbean 5.But it will give the Error.
    The code:
    <%@page import="java.util.*"%>
    <%@page import="javax.mail.*"%>
    <%@page import="javax.mail.internet.*"%>
    <%
    Properties props = System.getProperties();
    props.put("mail.smtp.host", "smtp.gmail.com" );
    props.put("mail.smtp.port", "465" );
    Session s = Session.getInstance(props, null);
    MimeMessage message = new MimeMessage(s);
    String From = request.getParameter("sender");
    InternetAddress from = new InternetAddress(From);
    message.setFrom(from);
    String Tos = request.getParameter("reciever");
    InternetAddress to = new InternetAddress(Tos);
    message.addRecipient(Message.RecipientType.TO, to);
    String sub =request.getParameter("subject");
    message.setSubject(sub);
    String mgs =request.getParameter("message");
    message.setText(mgs);
    Transport.send(message);
    %>
    <html>
    <p align="center">
    A Message has been sent. <br>
    Check your inbox.
    </p>
    <p align="center">
    Click here to send another!
    </p>
    </html>
    Error is :
    javax.servlet.ServletException: Could not connect to SMTP host: smtp.gmail.com, port: 465
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
         org.apache.jsp.MailBeema_jsp._jspService(MailBeema_jsp.java:88)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    root cause
    javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
    nested exception is:
         java.net.ConnectException: Connection timed out: connect
         com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
         com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
         javax.mail.Service.connect(Service.java:275)
         javax.mail.Service.connect(Service.java:156)
         javax.mail.Service.connect(Service.java:105)
         javax.mail.Transport.send0(Transport.java:168)
         javax.mail.Transport.send(Transport.java:98)
         org.apache.jsp.MailBeema_jsp._jspService(MailBeema_jsp.java:68)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

    javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
    nested exception is:
    java.net.ConnectException: Connection timed out: connectFairly self-explaining, isn't it? That host cannot be connected.
    Either check the correctness of the hostname/port, or check your network settings (firewall, router, etc).

  • Sending emails from jsp

    hi,
    I have a tomcat running on linux, database on oracle9i windows and mail server is exchange 2000
    I want to set reminders to the users of one portal ,
    like if they insert new data they should get reminders via email after first 7 days to update the data. if they do not update after 7 days an escalation should go to the managers for not updating data on 10th day.
    also i want to send a mail immediately when they insert the data for first time.
    help please.

    You can use the mailer taglib

  • HT3228 Need help sending email from iPhone 5S

    Have a new iPhone 5S and can receive email but every email I try to send is copied to the outbox and message says the recipient was rejected by the server. How do I fix that?

    You can't use iCloud to do that.  Any photos in iCloud must also be on your phone.  If you delete them from your phone, they will also be deleted from iCloud and they will be lost.  You might want to try updating your phone using iTunes on your computer (as explained at the bottom of this article: Update your iPhone, iPad, or iPod touch iOS software).  It requires much less space than updating over the air. 

  • How to send an email from jsp

    hello
    i want to send email from jsp
    the following is that code
    and i also downloaded the mail.jar and activation.jar
    and there is no error in the code
    but the email is not sent
    kindly tell me that what can be the reason
    <%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
    <%
    String from="[email protected]";
    String to="[email protected]";
    try{
    SmtpClient client = new SmtpClient("xx.xxx.xx.xx");//replace with the reqiured smtp
    client.from(from);
    client.to(to);
    PrintStream message = client.startMessage();
    message.println("To: " + to);
    message.println("Subject: Sending email from JSP!");
    message.println("This was sent from a JSP page!");
    message.println();
    message.println();
    message.println();
    client.closeServer();
    catch (IOException e){     
    System.out.println("ERROR SENDING EMAIL:"+e);
    %>

    try this:
    <html>
    <body>
    <form action="enviaremail.jsp" method="post">
    <table border="0" align="center" bgcolor="tan">
    <tr>
    <td><b>Para..:</b></td>
    <td><input type="Text" name="para"</td>
    </tr>
    <tr>
    <td><b>De..:</b></td>
    <td><input type="Text" name="de"</td>
    </tr>
    <tr>
    <td><b>Assunnto..:</b></td>
    <td><input type="Text" name="assunto"</td>
    </tr>
    <tr>
    <td colspan="2">
    <textarea name="mensagem" rows=10 cols=45></textarea>
    </td>
    </tr>
    </table>
    <center> <input type="Submit" value="Enviar Email"></center>
    </form>
    </body>
    </html>
    <html>
    <body>
    <%@ page import="jspbrasil.Email" %>
    <jsp:useBean id="email" class="jspbrasil.Email"/>
    <%
    try {
    String mailServer = "mail.seumailserver.com.br"
    String assunto = request.getParameter("assunto")
    String para = { request.getParameter("para") };
    String de = request.getParameter("de");
    String mensagem =request.getParameter("mensagem");
    email.sendSimpleMail(mailServer, assunto, para, de, mensagem);
    %>
    <p>Email enviado com Sucesso !!!</p>
    <%
    catch (AddressException e) { %>
    <p>Endere�o de Email inv�lido</p>     
    <%}%>
    <%
    catch (MessagingException e) { %>
    <p>Imposs�vel enviar o email.</p>     
    <%}%>
    </body>
    </html>
    package jspbrasil;
    import javax.mail.*;
    import javax.mail.internet.*;
    import.java.util.*;
    public class Email {
    public void sendSimpleMail (String mailServer, String subject,
    String to,String from, String mensagem)
    throws AddressException, MessagingException {
    Properties mailProps = new Properties();
    //defini��o do mailserver
    mailProps.put("mail.smtp.host", mailServer)
    Session mailSession = Session.getDefaultInstance(mailProps, null);
    //As duas linhas seguintes de c�digo, colocam no
    //formato de endere�os,
    //supostamente v�lidos, de email os dados
    //passados pelos par�metros to e from.
    InternetAddress destinatario = new InternetAddress (to);
    InternetAddress remetente = new InternetAddress (from);
    //As duas linhas de c�digo a seguir, s�o
    //respons�veis por setar os atributos e
    //propriedas necess�rias do objeto message
    //para que o email seja enviado.
    //inicializa��o do objeto Message
    Message message = new MimeMessage (mailSession);
    //Defini��o de quem est� enviando o email
    message.setFrom(remetente);
    //define o(s) destinat�rio(s) e qual o tipo do
    //destinat�rio.
    //os poss�veis tipos de destinat�rio: TO, CC, BCC
    message.setRecipient( Message.RecipientType.TO, destinat�rio );
    //defini��o do assunto do email
    message.setSubject (subject);
    //defini��o do conte�do da mensagem e do
    //tipo da mensagem
    message.setContent (mensagem.toString(), "text/plain");
    //a linha de c�digo seguinte � a respons�vel
    //pelo envio do email
    Transport.send (message);

  • Sending emails from ipad

    No problem sending emails from desktop Windows Live Mail, nor from BT email in BT.com but cannot send emails from ipad. No problem receiving them. Partner cansend and receive from all devices.
    Have asked for help/ call backs.Told need level 2 tech help. All times fixed for Level 2 call back ( now 3-4 times ) have not been honoured. Last one at 4.30 pm today. Am getting desperate.

    normandy wrote:
    No problem sending emails from desktop Windows Live Mail, nor from BT email in BT.com but cannot send emails from ipad. No problem receiving them. Partner cansend and receive from all devices.
    Have asked for help/ call backs.Told need level 2 tech help. All times fixed for Level 2 call back ( now 3-4 times ) have not been honoured. Last one at 4.30 pm today. Am getting desperate.
    Hi. Welcome to the forums.
    I'm afraid that the answer is pretty much one of your settings, or even possibly because you may not be on your internet connection via wifi.
    What errors are you getting ?
    Make sure that you are connected to the internet via your BTinternet connection rather than maybe any 3g/4g connection.
    But the main thing is to check those settings. What is the outgoing email server? What is the port setting? What is the SSL/TLS setting. And make sure smtp authentication is set on.
    Pop back with some answers
    http://www.andyweb.co.uk/shortcuts
    http://www.andyweb.co.uk/pictures

  • TS3899 In my iPad 2 with IO6 today I can not send emails from my gmail account, they go to the outbox directly...why? How can i solve this problem? ..I restarted the IPad but the problem was not solved. Please help.

    In my iPad 2 with IO6 today I can not send emails from my gmail account, they go to the outbox directly...why? How can i solve this problem? ..I restarted the IPad but the problem was not solved. Please help.

    Greetings,
    Questions:
    1. What version of the Mac OS are you running (Apple > About this Mac)?
    2. What version of the iOS are you running (Settings > About)?
    3. Do you use MobileMe/ iCloud or another server based sync solution like Google or Yahoo?
    4. Do other changes to synced information like Address Book content sync successfully back and forth?
    Based on your description it sounds like you have a 1 way sync issue.  Events sync fine between the iOS devices and fine from the computer to the iOS devices but not from the iOS devices to the computer.
    Try:
    Backup your computer and iOS devices before doing anything else:
    http://support.apple.com/kb/HT1427
    http://support.apple.com/kb/ht1766
    Ensure all the devices in use are fully up to date: Apple > Software Update / Settings > General > Software Update
    Make separate backups of critical data:
    Backup your computer Addressbook: http://docs.info.apple.com/article.html?path=AddressBook/4.0/en/ad961.html
    Backup your computer iCal: http://support.apple.com/kb/HT2966
    Reset syncing on your Mac: http://support.apple.com/kb/TS1627
    Reply back if that does not resolve your issue.
    Hope that helps.

  • HT1430 Cannot send email from iPhone 4S ..it keeps saying smpt password is incorrect but it is correct and I receive email no problem

    Cannot send email from iPhone...keeps saying smpt password is incorrect but it is correct.. I recieve email no problem

    On my own, I discovered the following, which worked (one responder got the solution part correct for Google): For Yahoo, where I just use a standard login with no extra verification, I had to go into Yahoo and change my password. Once I did this, the new iPhone had no problem registering accepting my Yahoo account. I WAS, however, using the correct password and user name all along, for those who did not think that was the case. The problem is on the iPhone software side. For Google, I use a two step verification, and for that, one must go to Google Mail and obtain a specific, unique password, that is designed to work only on iPhones. Hope this helps anyone else with this dilemma.

  • Problem in Sending email from Reports Queue Manager

    Hi
    I am getting problem in sending email from reports queue manager.
    It says that error in logging to mail server.
    If any body knows the sol then pl help me out.
    thanks

    Hi
    I am getting problem in sending email from reports queue manager.
    It says that error in logging to mail server.
    If any body knows the sol then pl help me out.
    thanks

  • Sending emails from the JSP application

    hi,
    I am trying to send emails from my jsp application using JavaMail API's.
    I am using my own mailserver.
    Iam able to send emails from my applications to the ids of my own mailserver but not the yahoo,gmail and rediff ids.
    Is it because of blocking of any firewall or somthing else to do within my application?
    Can anyone help me in this?
    Thanks a lot.

    Please read the JavaMail FAQ.
    It's probably due to the configuration of your mail server,
    which is refusing to relay your messages.

  • TS3899 Problems sending email from hotmail addresses in iPad Mail

    Hi
    I am having problems sending email from my hotmail addresses (live.com) in the Mail program on my iPad.  I get a message that says "An error occurred while sending this message".  Tis morning the program worked perfectly.  Now, not so much!
    I have turned my iPad off and on.  I have deleted and reinstalled the mail accounts.  Neither strategy helped.
    I have no problems with my gmail address.  I can send mail if I log on to the hotmail website in Safari.
    Any ideas?
    Thanks

    23circles:
    I would like to find a way to only have the gmail inbox but still send from any three of her accounts.
    You can do it this way:
    Set up only one account. The one from which you want to receive mail.
    In Mail > Preferences > Accounts > +gmail acct+ > Email Address insert the other email addresses, separating each with a comma and single space.
    Only the GMail account will receive incoming Mail. However, when you want to send from another address, in the From dropdown menu toggle the address from which you wish to send mail.
    You will, of course, delete the other accounts you have created to avoid getting incoming messages.
    cornelius

  • Problem sending emails from Entourage 04 for Mac

    Hello, hope this is the right forum, does anyone use Microsoft's Office/Entourage 04 for Macintosh for email? Perhaps you can help:
    Suddenly I can't SEND emails from six "sub" accounts I have, and get the error message "From: address not verified". These are all normally sent via a single primary (BTInternet.com) address which is entered in the "Sending Mail" account section and has been been set up like this for a year on my iMac.
    A seventh sub-account used by my partner on a different computer (PC using Outlook) also sends emails via the same primary address - and works fine..
    Obviously there is a problem logging to this primary address specifically in my Entourage.
    There is nothing wrong with the primary's own set-up because I can send messages from that (and the "sending" info is identical).
    (Also note: I can RECEIVE emails to all the accounts, no problem).
    Unless I've inadvertently clicked something I shouldn't, I'm mystified.
    I'm stuck as I use use one of the "subs" all the time. Help!

    After much research and help (on another site forum!) it turns out this is a BTYahoo! mail fault affecting many BT accounts (in the UK at least). Why they are messing accounts around I don't know.
    If anyone finds they can't send via a BT account just find another server and enter their details and all will work again - as I've discovered after a day trawling the ether!

Maybe you are looking for

  • Item Level

    Hi All, Can someone explain me what is the best option for Item's GL Method? Between Item Level/Item Group? Currently I am using Item group. I noticed that to use the Item Level, I need to enter the warehouse code for all the product. Is that correct

  • Garbage tables in oracle database

    Hi, Is there anyone can tell me whats wrong with my database. I dont know what is actually the problem is in my oracle scott database i got some garbage table name once i try to execute "select table_name from user_tables" command. Here is the output

  • Performance issues while opening business rule

    Hi, we're working with Hyperion version 9.2.1 and we're having some performance problems while opening business rules. I analyzed the issue and found out that it has something to do with assigning access privileges to the rule. The authorization plan

  • Do you know of a good flash drive tester for OSX?

    I know Disk Utility can verify pendrives, but it's not a deep test... it just seems to verify some partition tables or indices. I'd like to know if there's some tool capable of telling the status of cells in the flash drive.

  • New to JServer

    Hi, I am new to JServer and am not being able to find one to install for evaluation at Oracle site. Can anyone send me the URL ? From whatever documentations I have on JServer, it doesnot appear to me that it has any webserver bundled. Can anyone thr