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



Home Answers Viewqa JSP-Servlet JavaMail and Gmail in Windows
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Khushbu Arora
JavaMail and Gmail in Windows
0 Answer(s)      4 years and 11 months ago
Posted in : JSP-Servlet


Hello!

I made a java program to send and receive emails through Gmail SMTP server. It worked fine in Windows 7 but when I try to run the same program in Windows XP in a different machine, then the mail is not going. Either Messaging exception or SendMail exception comes. I have used JDK1.6 and NetBeans 5.5 to build this program.

Kindly let me know whether the issue is of operating system (in this case changes need to made accordingly) or some setting needs to be done in NetBeans, which somehow was taken by default in Windows 7.

The program is=

/*
* SendMail.java
*
* Created on 19 April, 2010, 10:14 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package utility;

import java.io.Console;
import javax.mail.*;
import javax.mail.internet.*;
//import javax.activation.*;
import java.util.*;


/**
*
* @author Khushbu
* @version
*/
public class SendMail {

String username=null;
String password=null;

/** Creates a new instance of SendMail */
public SendMail() {
}

public void postMail( String recipients[ ], String subject, String message, String from, String pwd) throws MessagingException
{
boolean debug = false;

//Set the host smtp address
Properties props = new Properties();
//props.put("mail.smtp.host", "smtp.live.com");

String host="smtp.gmail.com";
props.put("mail.smtps.auth", "true");


// Authenticator a1= new PopupAuthenticator();


// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);

// create a message
Message msg = new MimeMessage(session);

// set the from and to address
//InternetAddress addressFrom = new InternetAddress(from);
//msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
{
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type
msg.setSubject(subject);
//msg.setContent(message, "text/plain");
msg.setText(message);
//Transport.send(msg);

username = from;
password = pwd;

Transport t = session.getTransport("smtps");
try {
t.connect(host, username, password);
//t.connect(host, username);
t.sendMessage(msg, msg.getAllRecipients());
} finally {
t.close();
}

}

}





Advertisement
View Answers

Related Tutorials/Questions & Answers:
JavaMail and Gmail in Windows - JSP-Servlet
JavaMail and Gmail in Windows  Hello! I made a java program to send and receive emails through Gmail SMTP server. It worked fine in Windows 7 but when I try to run the same program in Windows XP in a different machine
gmail access using javamail API
gmail access using javamail API  how to coonect to gmail using java...://www.roseindia.net/javamail/ Hope that it will be helpful for you. Thanks   .../javamail/][2] Thanks [1]: http://www.roseindia.net/javamail/ [2]: http
Advertisements
JavaMail and Gmail - JSP-Servlet
JavaMail and Gmail  In my previous question, I forgot to mention that following exception is arising when trapped in catch: javax.mail.MessagingException: can't determine local email address Kindly let me know
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like
javamail in jsp - JavaMail
javamail in jsp  Hii Sir, I am working wuth a javamail programme... other gmail , yahoo or any other mail servers. I got an exception.... m40sm7925597waf.46 " when i am trying for mailing in gmail server. Could you
gmail authentication
gmail authentication  Hi... there... I observed that if we open gmail and in that in box then there will be some url like paste in another browser window it asks for authentication how it is possible if anybody knows plz tell
Mailing - JavaMail
Mailing  Dear Friends, How can i send mails to yahoo,gmail,other mail servers using javamail using a jsp file. Please help me
JAVAMAIL API - JavaMail
JAVAMAIL API  This is my code, but i got unnecessary data like ???]???????????? € ??? this how to avoid this WELCOME  
New Gmail Version for iPhone from Google, New iPhone Gmail, iPhone 3.0 Gmail
New Gmail for Apple iPhone Google launched the new version of its popular email service Gmail for the iPhone with a host of specially designed features... in the desktop version of Gmail. If you need to search your mail you can just key
JavaMail API usage - JavaMail
JavaMail API usage  Hello sir, i wrote a program to send a message from one mail account to another mail account,for that i uses JAVA and JSP two.../javamail/ Thanks. Amardeep
JavaMail flagging problems - JavaMail
JavaMail flagging problems  Hi everyone, I am working on receiving a mail currently. I use a substring "status" to search for the mail's subject line... the following link: http://www.roseindia.net/javamail/ Here you will get
JavaMail API - JavaMail
JavaMail API  Hi My Name is Satish I have a Problem with Java Mail API when I am doing Maling programme I can able to do single mail and single CC mail but I am not able to do multiple mails How can I do this thing? Any one can
java - JavaMail
java  How to send out an email using simple java  How to send out an email with attachment using simple java  Hi Friend, Please visit the following links: http://www.roseindia.net/javamail/ Thanks
java - JavaMail
java  Hi, i want to send a mail automatically particular time for every day so, please reply me  Hi Friend, Please visit the following link: http://www.roseindia.net/javamail/ Hope that that above link
forgotpassword - JavaMail
with running example. http://www.roseindia.net/javamail/ Thanks
extract content from javamail - JavaMail
extract content from javamail  Hi, I currently try the example(Read Multipart mail using Java Mail) on Javamail from the site to receive the e-mail. Then If I going to extract text the message content. What can I do
multiple file upload at a time like gmail
multiple file upload at a time like gmail  I want to upload multiple files at a time like gmail. is there any possiblity/solution to do that?   Hi Friend, Please visit the following link: Upload Multiple Files Thanks
getting contacts from gmail - JSP-Servlet
getting contacts from gmail  hi there, would you please tell me step by step how can i integrate the gmail contacts with my web application. please reply me asap. I'll be greatfull to you. Rajesh
How to get New Gmail Inbox?
With the introduction of new Gmail Inbox by Google recently, it has been more.... This tutorial will teach you How to get Gmail Inbox easily to enjoy the new experience of Gmail inbox. Recently Google rolled its brand new look of Gmail
windows username - JSP-Servlet
windows username  how to reset the password and username of windows using jsp
how to create a jsp page like gmail inbox page
how to create a jsp page like gmail inbox page  in my struts project i need to create a page like gmail inbox page..........how can i create this? help me some one
Direct jsp coding for gmail login page and to open mail
Direct jsp coding for gmail login page and to open mail  DEAR SIR, i'm urgently in need of jsp coding to create login page of gmail and to open mail
java code to send email using gmail smtp server
java code to send email using gmail smtp server  please send me the java code to send email using gmail smtp server. and how to send verification code
Running Jar file in Windows
Running Jar file in Windows  Running Jar file in Windows
Windows File Protection
Windows File Protection  I would like to know if there is any way to place a file or folder under windows protection such that it can't be deleted, or in generel if there is a way to prevent a file or folder from being deleted
 

 

 

DMCA.com