TRYING TO SEND AN EMAIL VIA JSP not working

I think what im doing is right but i keep getting errors...therefore...its wrong..
<form action="mailer.jsp" method="post">
     To :<br>
     <input type="text" name="to" class="std"></input><br>
     From :<br>
     <input type="text" name="from" class="std"></input><br>
     Subject :<br>
     <input type="text" name="subject" class="std"></input><br>
     Message :<br>
     <textarea rows="10" cols="80" name="message"></textarea>
     <br>
     <input type="submit" value="Send"></input>
     </form>Mailer.jsp
<div class="frame">
     <jsp:useBean id="mailer" class="com.stardeveloper.bean.test.MailerBean">
          <jsp:setProperty name="mailer" property="*"/>
          <% mailer.sendMail(); %>
     </jsp:useBean>
     Email has been sent successfully.
     </div>MailerBean.java
package com.stardeveloper.bean.test;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
public final class MailerBean extends Object implements Serializable {
     /* Bean Properties */
     private String to = null;
     private String from = null;
     private String subject = null;
     private String message = null;
     public static Properties props = null;
     public static Session session = null;
     static {
          /*     Setting Properties for STMP host */
          props = System.getProperties();
          props.put("mail.smtp.host", "mail.brunel.ac.uk");
          session = Session.getDefaultInstance(props, null);
     /* Setter Methods */
     public void setTo(String to) {
          this.to = to;
     public void setFrom(String from) {
          this.from = from;
     public void setSubject(String subject) {
          this.subject = subject;
     public void setMessage(String message) {
          this.message = message;
     /* Sends Email */
     public void sendMail() throws Exception {
          if(!this.everythingIsSet())
               throw new Exception("Could not send email.");
          try {
               MimeMessage message = new MimeMessage(session);
               message.setRecipient(Message.RecipientType.TO,
                    new InternetAddress(this.to));
               message.setFrom(new InternetAddress(this.from));
               message.setSubject(this.subject);
               message.setText(this.message);
               Transport.send(message);
          } catch (MessagingException e) {
               throw new Exception(e.getMessage());
     /* Checks whether all properties have been set or not */
     private boolean everythingIsSet() {
          if((this.to == null) || (this.from == null) ||
             (this.subject == null) || (this.message == null))
               return false;
          if((this.to.indexOf("@") == -1) ||
               (this.to.indexOf(".") == -1))
               return false;
          if((this.from.indexOf("@") == -1) ||
               (this.from.indexOf(".") == -1))
               return false;
          return true;
}

I think what im doing is right but i keep getting
errors...therefore...its wrong..i don't see any errors posted, so it must not be wrongThe error occurs because the OP did not use BSD-style braces.

Similar Messages

  • When trying to send an email I can not access "insert addresses" link, what is wrong?

    I am using Windows XP and when trying to send an email using Yahoo email I can not insert address from that link. It will not open. I can not find a way to solve this. Help. Thanks

    See this:
    [http://support.mozilla.com/en-US/kb/Changing+the+e-mail+program+used+by+Firefox]

  • HT4519 I'm trying to send out email but will not send. How can I stop this on my IPhone4?

    I'm trying to send out an email but it will not send. How can I stop this on my phone?

    See:
    iOS: Unable to send or receive email
    It appears you have a incorrect entry in the setup. Google for:
    setup xx email on iphone
    where xx is your provider.

  • HT204053 I'm trying to send e mails but is not working comeback asking to replace the email address I'm sending int from

    my email ios not working when i try sending a email it comeback and ask to have e mail address change
    my email need to say off line or on line to be able to send e mail

    Hello ivanstudioladesigns,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    iOS: Adding an email account
    http://support.apple.com/kb/ht4810
    Have a nice day,
    Mario

  • Emails via Iphone not working any more

    Hi, I have a email account with yahoo, did work perfectly till today, after sending emails via Iphone nothing is happening, no message in fowlder sent and also the recipient does not get my mail. Tested: sending photo via email and text email
    Second problem: I had twice that my Iphone did not react at all on touching the screen, had to shut down the phone and switch it on again.....
    Has anyone any ideas, and sorry for my english....
    Andreas from Germany

    Yahoo mail on the iphone has an issue with sending emails that have attachments, like a picture, usually it does not send at all or if it does the attachment is gone. I think its because the iphone still uses yahoo mail classic which handles attachments strangely. So if the emails your sending that are disappearing have attachments then thats why. I've found that when dealing with attachments it works better if you use the mobile version of yahoo.
    As for the touch stopping working...probably just the nature of software and OS's in general. They all crash and freeze up and all have to be rebooted from time to time.

  • Trying to listen to WFAN via iTunes - not working

    I can successfully listen to WFAN in NY via QuickTime and WMP. I'd like to try listening through iTunes, but cannot get it to work. I have the URL which ends in .asx. I can listen to the sample Apple provides in help, so I would guess my firewall is not the issue. Is this type of URL not compatible with iTunes? Any suggestions?

    I think what im doing is right but i keep getting
    errors...therefore...its wrong..i don't see any errors posted, so it must not be wrongThe error occurs because the OP did not use BSD-style braces.

  • Sending an email through JSP and WML

    I am trying to send an email through jsp in wml, i think i have everything set up properly with regards to tomcat however I keep getting the error
    "Invalid element 'PCDATA' in context of card expected on event ....."
    The line of code in which this occurs is           
    <jsp:setProperty name="mailer" property="*"/>
    I was wondering if anyone would be able to help me with this and be able to tell me why it thinks this is PCDATA and not jsp code.
    Any help would be much appreciated.

    Check out:
    http://jakarta.apache.org/taglibs/index.html

  • In iphoto my photos do no appear just a blank dated square. Somehow I messed up when trying to send a photo via email.I cannot not see any but 4 photos.

    Help!   In iphoto my photos do not appear just a blank dated square. Somehow I messed up when trying to send a photo via email.I cannot not see any but 4 photos.I tried all of the solutions that Apple suggested. Somehow I think that i am trying to send ALL my photos in an email.How do i unhide all of my photos?

    Did you launch iPhoto with the Option(Alt) and Commnad keys held down like Terence suggested?  If you did it properly you will get this window:
    The second option is the one you want to run.
    OT

  • When trying to send a photo via email, I am prompted to setup an email account even though email is already setup.  What would cause this?

    when trying to send a photo via email, I am prompted to setup an email account even though email is already setup.  What would cause this?  Better yet, how do I fix it?

    I have checked this on my device.  I see a Default account under Messages created outside of Mail will be sent from the default account.  There is an account selected, though it does not show my exchnage account.  If it is only an exchange accout, can that not be used for this?

  • When trying to send E-mail via AOL i get the message "rejected by the server because it does not allow relaying" I have checked settings as per answers to similar question

    When trying to send E-mail via AOL i get the message "rejected by the server because it does not allow relaying" I have checked settings as per answers to similar question

    From which account does the email not send?  When sending from an account, the iPad will first try to use the aoutgoing server for that account.  If it can't it will try the other accounts listed.in the setting on the iPad for that account.  It soulds like the server for the account is not working and that the alternate server is resjecting the messag since it did not originate ffrom the account associated with that server,  That is to prevent sending spam.

  • I tried to send an email and it said it failed because I was not connected to the server. I also cannot open a new email

    I tried to send an email but it said I was not connected to the server. I also cannot open a new email

    I use hotmail. I went to hotmail sign in on the Internet and retrieved my email without any problem. I checked my settings and they are correct

  • Unable to send out emails via outlook express since 06/29/2010

    Task '[email protected]" - Sending' reported error (0x80042109) : 'Outlook is unable to connect to your outgoing (SMTP) e-mail server. If you continue to receive this message, contact your server administrator or Internet service provider (ISP).'        This is a copy/paste of error message from Office Outlook  2003
    Our household has been unable to "send" outgoing emails since 06/29/2010.  This includes a wireless laptop and a PC. We both lost the ability to send emails same day.  We changed NOTHING and did not share emails with each other that would have corrupted our system. During this time I have had 2 Verizon techs dance around in the PC doing all the same things I did as well as what  the automated assistant did.  The last tech said the Outlook Express 6.0 was corrupted, and to unistall it and then reinstall;  this time 2 hours later, I think he just gave up).  That did not work either.  I tried using the Outlook Office and still got an error message for outging. Everything is set up as it was when it was working until 06/29/2010.  I was told that there was a new server being installed and that things wold be working by 07/02/2010... I have tried taking down the firewall, turning off virus protection (McAfee), changing from outgoing.yahoo.verizon.net to just outgoing.verizon.net, checking boxes, unchecked boxes. SMPT is set to 587.  We get incoming fine.  I hate using the "Verizon email site" as too much monkey motion to get to mail, but that's what we have been doing.  I even tried setting up a GMail account, again got mail still could not send.  Any ideas?

    Thank you for your response!  I even tried sending an email via dos prompt  with Telnet, got past "HELO", but when trying to get a  "RCPT TO"  (using outgoing.yahoo.verizon.net)  I got an "authorization required" response and then was dropped.  I have been passed around without a solution. I am about ready to change ISP, but really hate to as most of the time (years now) this has been a decent ISP. If Verizon is having a problem just say so, I can handle it, honesty would be nice, refreshing and not wasting so much of my time as well as the techs!

  • Sending an email in JSP

    hi,
    Im trying to send an email in a jsp page, you can see what ive done below. Currently im not entering any username or password for my gmail account - where/how can i do this, also can i send emails using my gmail in a jsp page.
    <%@page import="sun.net.smtp.SmtpClient, java.io.*" %>
        String username="blah";
        String remail = request.getParameter("remail");
        String msg = request.getParameter("message");
        String subject = "I found a great new product";
        String smtp = "smtp.gmail.com";   
        try{
             SmtpClient client = new SmtpClient(smtp);
             client.from(username);
             client.to(remail);
             PrintStream message = client.startMessage();
             message.println("To: " + remail);
             message.println("Subject: "+subject);
             message.println(msg);
             client.closeServer();
         catch (IOException e){     
             System.out.println("ERROR SENDING EMAIL:"+e);
         }

    i have create a class file like follows and create its objects in jsp file then i can do this the java file as follows
    package exceltoxml;
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Session;
    import javax.mail.PasswordAuthentication;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.InternetAddress;
    import javax.mail.Address;
    import javax.mail.Transport;
    import java.util.Enumeration;
    public class SendMail
         MimeMessage message;
         public SendMail()
              try
              Properties properties=new Properties();
    ////////////////from gmail
                   properties.setProperty("mail.smtp.host","smtp.gmail.com");
                   properties.setProperty("mail.debug","false");
                   properties.setProperty("mail.smtp.auth","true");
                   properties.setProperty("mail.smtp.port","587");
                   properties.setProperty("mail.smtp.starttls.enable","true");
    ////////////////fram yahoo///////////////////          
              //properties.setProperty("mail.smtp.host","smtp.mail.yahoo.co.in");
              //properties.setProperty("mail.smtp.port","587");
              //properties.setProperty("mail.smtp.auth","true");
              //properties.setProperty("mail.debug","false");
              Authenticator authenticator=new Authenticator()
                   public PasswordAuthentication getPasswordAuthentication()
                        return new PasswordAuthentication("from mail id","your password");
              Session session=Session.getInstance(properties,authenticator);
              message=new MimeMessage(session);          
              Address fromaddress=new InternetAddress("from mail id");          
              message.setFrom(fromaddress);          
              }catch (Exception x){System.out.println("one :"+x);}
         synchronized public void sendMail(String messText,String messSubject,String address)
              try{
              message.setText(messText);          
              message.setSubject(messSubject);
              Address toaddress=new InternetAddress(address);
              message.addRecipient(javax.mail.Message.RecipientType.TO,toaddress);
              Transport.send(message);
              }catch(Exception e){System.out.println("two :"+e);}
    for this you must have two jmail jar files. activation.jar and mail.jar

  • Sending an email via AppleScript and Dialogue Boxes

    I am trying to write a script to send an email via Mail of which the body of the message is from a dialogue box. I decided upon using Automator and AppleScript. I have, so far, the following workflow:
    1. Run Apple Script:
    set mypass to text returned of (display dialog "What are you doing?" with icon 1 buttons {"Tweet", "Cancel"} default button "Tweet" default answer "")
    2. New Mail Message.
    3. Send Outgoing Messages.
    4. Run Apple Script:
    on run {input, parameters}
    tell application "System Events" to set visible of process "Mail" to false
    return input
    end run
    I wand this workflow to allow the user to input an answer and this answer to be in the message field of the email. I can use the "Ask for Text" action in Automator but it does not allow for any control over the appearance of the dialogue box. The first script returns the result "<whatever is typed>" (ie. "Test") in the Results field below the script box, as does the "Ask for Text" action but it does not insert it into the message. Does anyone know what is going wrong here?
    I am relatively new to AppleScript which is why I am using Automator but would like any information on how this could be done entirely in AppleScript. My previous attempts at sending email using script was unsuccessful.
    My aim is to save this as an Application with a proper icon.

    see my reply to your post in the snow leopard forum.
    http://discussions.apple.com/thread.jspa?messageID=10318297&#10318297

  • I cant send an email via UTL_MAIL : ERROR NO 530

    hi .. i want to send an email via UTL_MAIL package. I am using ORACLE XE 10g.
    I am trying this code :
    declare
    i INTEGER;
    BEGIN
    UTL_MAIL.send('[email protected]','[email protected]',NULL,NULL,'DENEMEKONU','DENEMEMESAJ',NULL,NULL);
    END;
    then, i encounter this error:
    ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first.....
    I made settings of smtp mail with:
    ALTER SYSTEM SET SMTP_OUT_SERVER='smtp.gmail.com';
    But i am getting this error consistently.
    How can i solve this problem, thanx.

    Hello Kadir,
    any errors, NDRs, logs that you could provide? How do you know the messages are not getting trough to that address?
    Regards,
    Andreas

Maybe you are looking for