Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


gautamshetkar
mail problem
0 Answer(s)      3 years and 8 months ago
Posted in : JSP-Servlet


Sir, I tried ur send mail example but it giveng follwing error "Could not connect to SMTP host: localhost, port: 25" ,tried sendind from my gmail ac to rediffmail ac

mailapi

<html>
    <head>
        <title>Mail API</title>
    </head>
    <body><table border="1" width="50%"  cellpadding="0" cellspacing="0">
            <tr>
                <td width="100%">
                    <form method="POST" action="mail.jsp">
                        <table border="1" width="100%" cellpadding="0" cellspacing="0">
                            <h1>Mail API</h1>
                            <tr>
                                <td width="50%"><b>To:</b></td>
                                <td width="50%"><input type="text" name="to" size="30"></td>
                            </tr>
                            <tr>
                                <td width="50%"><b>From:</b></td>
                                <td width="50%"><input type="text" name="from" size="30"></td>
                            </tr>
                            <tr>
                                <td width="50%"><b>Subject:</b></td>
                                <td width="50%"><input type="text" name="subject" size="30"></td>          </tr>          <tr>
                                <td width="50%"><b>Description:</b></td>
                                <td width="50%"><textarea name="description" type="text"     cols="40" rows="15" size=100>      </textarea>
                                </td>          </tr>          <tr>
                                <td><p><input type="submit" value="Send Mail" name="sendMail"></td>
                            </tr>
                        </table>       
                    </form>  </td>
            </tr>
        </table>
    </body>
</html>

mail.jsp

<html>
    <head>
        <title>Mail</title>
    </head><body>
<%
try{  Session mailSession = Session.getInstance(System.getProperties());
Transport transport = new SMTPTransport(mailSession,new URLName("localhost"));
 transport.connect("localhost",25,null,null);
  MimeMessage m = new MimeMessage(mailSession);
  m.setFrom(new InternetAddress(%><%request.getParameter("from")%><%));
  Address[] toAddr = new InternetAddress[] {
                 new InternetAddress(%><%request.getParameter("to")%><%)
                              };
                              m.setRecipients(javax.mail.Message.RecipientType.TO, toAddr );
                               m.setSubject(%><%request.getParameter("subject")%><%);
                               m.setSentDate(new java.util.Date());
                               m.setContent(%><%request.getParameter("description")%><%, "text/plain");
                                transport.sendMessage(m,m.getAllRecipients());
                                 transport.close();
                                 out.println("Thanks for sending mail!");
}
catch(Exception e){
     out.println(e.getMessage());
      e.printStackTrace();
}
                               %>
    </body>
</html>

Please help Thanks.


Advertisement
View Answers

Related Tutorials/Questions & Answers:
mail problem
mail problem  Sir, I tried ur send mail example but it giveng...; <title>Mail API</title> </head> <body><table...;Mail API</h1> <tr>
iphone mail sending problem
iphone mail sending problem  Hi, I'm receiving the following error ... while sending mail in my iphone application Terminating app due to uncaught... it done myself... actually in my send mail code i have predefined the mailto id
Advertisements
send the mail with attachment problem - Struts
send the mail with attachment problem  Hi friends, i am using the below code now .Here filename has given directly so i don't want that way. i need... mail server properties.setProperty("mail.smtp.host", host
problem in viewing the mail's content using javamail
problem in viewing the mail's content using javamail  i'm using the following code to view a mail in a javamail application problem i'm facing... as if they are body of the mail. Secondly in some mails i'm getting the following Exception
mail
mail  I wrote a program to send mail using smtp. But there is an error message " could not connect to smtp.gmail.com port 465. what is the problem how can i solve it ...   Please visit the following link: Java Mail API
mail
mail  how to send mail using jsp   Please visit the following links: JSP Send Mail Java Mail Tutorials
problem in getting mail exchange records(MX) using DNS (glassfish(struts2))
problem in getting mail exchange records(MX) using DNS (glassfish(struts2))  Hi, dummy.jsp <%@page import="javax.naming.Context"%> <%@page import="java.util.Hashtable"%> <%@page import
problem in getting mail exchange records(MX) using DNS in java
problem in getting mail exchange records(MX) using DNS in java  Hi, jsp file: <%@page import="javax.naming.NamingEnumeration"%> <%@page import="javax.naming.Context"%> <%@page import="java.util.Hashtable
java mail
java mail  By Which code or function i can send E-mail to given E-mail Address   Hi Friend, Please visit the following link: Java Mail Thanks   Hi Friend, Please visit the following link: Java Mail
java mail
java mail example  how to download javamail software give one examples   Please visit the following link: Java Mail API
java mail programs
java mail programs  I got some codes from this about sending mail,forwarding mail,multipart mail etc..and I compiled and executed it,but it did... output.actually,do I need a mail server to get correct output of these codes?plz help me, I
php mail
php mail  how to send the submitted form to mail after 24 hours? pls help me
java mail api - JavaMail
java mail api  Hi, Pls give me the detailed information on how... in the code..   Hi friend, For solving the problem remember some points : 1.Download the Apache Mail server (James) http://james.apache.org
Confirmation Mail
Confirmation Mail  hi, i need the code.when we sign up it will send the confirmation mail to the e-mail right.how to do that part.....and also help me whether the AJAX is better or PHP better for the front design
java mail
java mail  how to download javamail software give one examples   Please visit the following link: Java Mail API
java mail
Mail API is now open source and you can download the source code and read. If you want to understand the working of Java Mail download the source code from here and learn the coding logic behind Java Mail. You can even compile the source code
send the mail with attachment - Struts
the mail . Mail Problem is file path: how to get the file path from the browse("we...send the mail with attachment   Hi Freinds, i am sending the mail without attachment file now. But i need to send the mail with attachment
java mail
) throws MessagingException, AddressException { // Setup mail...("mail.smtp.host", mailServer); // Get a mail session Session session = Session.getDefaultInstance(props, null); // Define a new mail message Message
java mail
java mail  Hi deepak, sorry to trouble again but with reference to apache mail server (james) tutorial i use the link that u have provided it redirects to apache offical site what there 4 zip and taz
java mail
(); out.println("Thanks for sending mail!"); } catch(Exception e
java mail - Java Beginners
java mail  how to send a mail without authentication one domain to another in java?  hi elumalai, check yourself, this is user problem.  Hi, You have to use the Java mail api. You need to use the SMTP
Java Mail exception - JavaMail
Java Mail exception  Hi! I am developing E-mail Client (GMAIL) program using JSP technology. Till now i dont have any problem. From last 3 days while i am connecting to the Gmail, I am getting the following exception... Whats
JAVA MAIL - JavaMail
JAVA MAIL  Hi! I am doing project called "E-mail Client". In this i want to view attachments which are in my mail in my application. I have tried... cannot be applied to multipart... how to get my mail attachments in my
mail with multiple attachments
mail with multiple attachments  code for sending mail with multiple attachments in jsp
Compose mail by clicking on send mail button
Compose mail by clicking on send mail button  How i get microsof out look page opend for composing mail by just clicking on send mail button and when outlook page open then in to:my email id is written on my jsp page
Java Mail - JMS
, For solving the problem visit to : http://www.roseindia.net/mail/sending-an-email... running very well,creating no other problems. Now i am trying to learn java mail service. I hav written a sample mail program to just test the code.The code
configure mail sever
configure mail sever  which is the best server for java mail?   Hi, James is the best mail server in Java. You can download the James for free. Read more at Apache Mail server. Thanks
Java Mail API Tutorial
Java Mail API Tutorial  I have to write programs using the Java Mail API. I want to learn the Java Mail API. Let's know the urls to learn Java Mail... Mail API. The Java Mail API allows you to send, read emails from Java program
php send mail with attachment
php send mail with attachment  Syntax of sending email with attachment in PHP
send mail in PHP
send mail in PHP  what are configurations needed to send mail in php.ini file by localhost ,please give me complete details about this,and code in datail
An E-mail protocol for storage
An E-mail protocol for storage  An E-mail protocol for storage, management and change, espically in corporate offices- a) Message handlindling services, b) Postal Service's, C) Data Storage, D)All of the above, e) None
Advertisements
 

 

 

DMCA.com