• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

please clear me

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai
please clear me

step 1:

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

public class SimpleSendMessage
{
public static void main(String[] args)
{
String host="smtp.gmail.com";
String to="[email protected]";
String from="[email protected]";

String subject=" THUSHARA PG COLLEGE..";

String messageText=" i am sending a message using the JAVA API \n";

boolean sessionDebug=false;

Properties prop=System.getProperties();
prop.put("mail.host",host);
prop.put("mail.transport.protocol","smtp");

Session session=Session.getDefaultInstance(prop,null);

session.setDebug(sessionDebug);

try
{
Message msg=new MimeMessage(session);
msg.setFrom(new InternetAddress(from));

InternetAddress []address={new InternetAddress(to)};

msg.setRecipients(Message.RecipientType.TO,address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);

Transport.send(msg);
}
catch(MessagingException e)
{
e.printStackTrace();
}

System.out.println("yes...............................!");
}
}

step 2: james server is running in my localhost
step 3: i connected to internet


----------------

RUNTIME ERROR;

javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command f
irst. l22sm336876waf.10

at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at SimpleSendMessage.main(SimpleSendMessage.java:40)
yes...............................!


please clear me
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what is happening exactly, but for tracking down a problem it's a good idea to turn on session debugging. That produces all kinds of useful output. Secondly, when using gmail as the server you'll need to add authentication and provide your password. Lastly, if you want to use a locally running server, you'll need to use "localhost" as server, not gmail.
[ April 08, 2008: Message edited by: Ulf Dittmer ]
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you want to test locally, you could try apache james..

regards
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic