🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.linux
Article #237

null pointer exception in sending mail

#237
From: kapilawate
Date: Sat, 16 Sep 2006 02:28
45 lines
2323 bytes
hi,

i am working on mailserver project. i want to send mail to any account.
my programs compiles successfully but gives the null pointer expection
when i try to execute the program. i am using javamail api for coding
purpose and linux as os. we are succesfully established the domain
mail.simon.com but are unable to execute as null ptr exception is
thrown. so if anybody has an idea then plz help us. i am also providing
my code with this,

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

public class Assimilator
{
	public static void main(String[] args)
	{
		try
		{
				Properties props = new Properties();
				props.put("mail.host","email.simon.com");

				Session mailConnection = Session.getInstance(props,null);
				Message msg = new MimeMessage(mailConnection);

				Address from = new InternetAddress("kapil@email.simon.com");
				Address to = new InternetAddress("simon@email.simon.com");

				msg.setContent("Hello! how are you?..........","text/plain");
				msg.setFrom(from);
				msg.setRecipient(Message.RecipientType.TO,to);
				msg.setSubject("Trial");

				Transport.send(msg);
				System.out.println("good");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}

thanks.
Technical Details
Message-ID: <1158373690.078566.292780@k70g2000cwa.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 107590,91ba2eaa462954e7,start
X-Google-Attributes: gid107590,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail
From: kapilawate@gmail.com
Newsgroups: borland.public.jbuilder.linux
Subject: null pointer exception in sending mail
Date: 15 Sep 2006 19:28:10 -0700
Organization: http://groups.google.com
Lines: 46
Message-ID: <1158373690.078566.292780@k70g2000cwa.googlegroups.com>
NNTP-Posting-Host: 59.161.3.42
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1158373695 27718 127.0.0.1 (16 Sep 2006 02:28:15 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 16 Sep 2006 02:28:15 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: k70g2000cwa.googlegroups.com; posting-host=59.161.3.42;
   posting-account=r1HSCg0AAABnARx0WN-vddUPJi6BG-oQ