JavaMail and Gmail in Windows

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, 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();
}

}

}




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
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
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
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
Version of javamail>javamail dependency
List of Version of javamail>javamail dependency
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
JAVAMAIL API - JavaMail
JAVAMAIL API  This is my code, but i got unnecessary data like ???]???????????? € ??? this how to avoid this WELCOME  
ModuleNotFoundError: No module named 'gmail'
ModuleNotFoundError: No module named 'gmail'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'gmail' How to remove the ModuleNotFoundError: No module named 'gmail'
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
Artifacts of javamail
List of Artifacts of javamail maven depenency
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
ModuleNotFoundError: No module named 'gmail-client'
ModuleNotFoundError: No module named 'gmail-client'  Hi, My Python... 'gmail-client' How to remove the ModuleNotFoundError: No module named 'gmail-client' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'gmail-forwarding'
ModuleNotFoundError: No module named 'gmail-forwarding'  Hi, My... named 'gmail-forwarding' How to remove the ModuleNotFoundError: No module named 'gmail-forwarding' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'gmail-trainer'
ModuleNotFoundError: No module named 'gmail-trainer'  Hi, My... 'gmail-trainer' How to remove the ModuleNotFoundError: No module named 'gmail-trainer' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sending_gmail'
ModuleNotFoundError: No module named 'sending_gmail'  Hi, My... 'sending_gmail' How to remove the ModuleNotFoundError: No module named 'sending_gmail' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cloudwright-gmail'
ModuleNotFoundError: No module named 'cloudwright-gmail'  Hi, My... named 'cloudwright-gmail' How to remove the ModuleNotFoundError: No module named 'cloudwright-gmail' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'gmail-client'
ModuleNotFoundError: No module named 'gmail-client'  Hi, My Python... 'gmail-client' How to remove the ModuleNotFoundError: No module named 'gmail-client' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'gmail-forwarding'
ModuleNotFoundError: No module named 'gmail-forwarding'  Hi, My... named 'gmail-forwarding' How to remove the ModuleNotFoundError: No module named 'gmail-forwarding' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Gmail-Notify'
ModuleNotFoundError: No module named 'Gmail-Notify'  Hi, My Python... 'Gmail-Notify' How to remove the ModuleNotFoundError: No module named 'Gmail-Notify' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'gmail-trainer'
ModuleNotFoundError: No module named 'gmail-trainer'  Hi, My... 'gmail-trainer' How to remove the ModuleNotFoundError: No module named 'gmail-trainer' error? Thanks   Hi, In your python
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
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
forgotpassword - JavaMail
with running example. http://www.roseindia.net/javamail/ Thanks
Maven Repository/Dependency: javamail | javamail
Maven Repository/Dependency of Group ID javamail and Artifact ID javamail. Latest version of javamail:javamail dependencies. # Version Release Date You can read more at: Maven
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
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
javamail
Version of geronimo>javamail dependency
List of Version of geronimo>javamail dependency
Version of javamail>mail dependency
Maven Dependency javamail >> 1.3.1
You should include the dependency code given in this page to add Maven Dependency of javamail >> javamail version1.3.1 in your project
Maven Dependency javamail >> 1.3.2
You should include the dependency code given in this page to add Maven Dependency of javamail >> javamail version1.3.2 in your project
Maven Dependency javamail >> 1.3.3
You should include the dependency code given in this page to add Maven Dependency of javamail >> javamail version1.3.3 in your project
ModuleNotFoundError: No module named 'gmail-yaml-filters'
ModuleNotFoundError: No module named 'gmail-yaml-filters'  Hi, My... named 'gmail-yaml-filters' How to remove the ModuleNotFoundError: No module named 'gmail-yaml-filters' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'swagger-gmail-client'
ModuleNotFoundError: No module named 'swagger-gmail-client'  Hi...: No module named 'swagger-gmail-client' How to remove the ModuleNotFoundError: No module named 'swagger-gmail-client' error? Thanks   Hi
ModuleNotFoundError: No module named 'gmail-api-wrapper'
ModuleNotFoundError: No module named 'gmail-api-wrapper'  Hi, My... named 'gmail-api-wrapper' How to remove the ModuleNotFoundError: No module named 'gmail-api-wrapper' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'magen-gmail-client'
ModuleNotFoundError: No module named 'magen-gmail-client'  Hi, My... named 'magen-gmail-client' How to remove the ModuleNotFoundError: No module named 'magen-gmail-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'gmail-yaml-filters'
ModuleNotFoundError: No module named 'gmail-yaml-filters'  Hi, My... named 'gmail-yaml-filters' How to remove the ModuleNotFoundError: No module named 'gmail-yaml-filters' error? Thanks   Hi, In your
Maven Repository/Dependency: org.jvnet.mock-javamail | mock-javamail
Maven Repository/Dependency of Group ID org.jvnet.mock-javamail and Artifact ID mock-javamail. Latest version of org.jvnet.mock-javamail:mock-javamail dependencies. # Version Release Date
Java Mail - JavaMail
Java Mail  how to email using Java mail or automatic generated mail???  Hi Friend, Please visit the following link: http://www.roseindia.net/javamail/ Hope that it will be helpful for you. Thanks
sending emails - JavaMail
sending emails  what is the code for sending emails in java  Hi Friend, Please visit the following link: http://www.roseindia.net/javamail/ Hope that it will be helpful for you. Thanks
java mail - JavaMail
java mail  how to send a mail without authentication in java ?  Hi Friend, Please visit the following link: http://www.roseindia.net/javamail/ Hope that it will be helpful for you. Thanks
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

Ads