Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Send an email with Nokia 6610  (Read 1739 times)
0 Members and 1 Guest are viewing this topic.
Offline josh1977

Innocent Bystander




Java games rock!


« Posted 2004-03-17 10:25:55 »

I need to send an email with Nokia 6610 from a Jar app.
I want to ask only smtp server,destination email and email text.
How can i do ?

Thanks
Offline vrm

Junior Devvie




where I should sign ?


« Reply #1 - Posted 2004-03-17 11:01:18 »

perhaps that :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
import java.net.*;
import java.io.*;

public class sendElvisMail {
public static void main(String s[]) {
   //
   //  Send fake mail from Elvis Presley
   //
   //  sendElvisMail [mail server] [recipient address]
   //               mail server can be hostname or IP address
   //
   //   ex.  sendElvisMail mail.company.com myFriend@somewhere.qc.ca
   //
   sendElvisMail t = new sendElvisMail();
   t.sendMail(s[0], s[1]);
   }

public void sendMail(String mailServer, String recipient) {
   try {
      Socket s = new Socket(mailServer, 25);
      BufferedReader in = new BufferedReader
          (new InputStreamReader(s.getInputStream(), "8859_1"));
      BufferedWriter out = new BufferedWriter
          (new OutputStreamWriter(s.getOutputStream(), "8859_1"));

      send(in, out, "HELO theWorld");
      // warning : some mail server validate the sender address
      //           in the MAIL FROm command, put your real address here
      send(in, out, "MAIL FROM: <Elvis.Presley@jailhouse.rock>");
      send(in, out, "RCPT TO: " + recipient);
      send(in, out, "DATA");
      send(out, "Subject: In the ghetto");
      send(out, "From: Elvis Presley <Elvis.Presley@jailhouse.rock>");
      send (out, "\n");
      // message body
      send(out, "I'm alive. Help me!");
      send(out, "\n.\n");
      send(in, out, "QUIT");
      s.close();
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }

 public void send(BufferedReader in, BufferedWriter out, String s) {
   try {
      out.write(s + "\n");
      out.flush();
      System.out.println(s);
      s = in.readLine();
      System.out.println(s);
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }

 public void send(BufferedWriter out, String s) {
   try {
      out.write(s + "\n");
      out.flush();
      System.out.println(s);
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #2 - Posted 2004-03-17 11:08:43 »

Quote
I need to send an email with Nokia 6610 from a Jar app.
I want to ask only smtp server,destination email and email text.
How can i do ?

Thanks


? Can you download extra JAR's onto the phone ?

If so, Sun has an official email API (javax.mail.* and friends) which you can find and download from java.sun.com. The version I usually use is about 350k in two jar files which you just drop into the directory (or preferably into your JVM's EXT directory) - which is probably way too big for you? Smiley

With that API, your code ends up something like this (copied and pasted from a real project):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
      Properties mailConfig = new Properties();

      mailConfig.put( "mail.smtp.host", "localhost" );
     
      // Any special options, special message type, attachments, etc
      Session mailSession = Session.getInstance( mailConfig, null );
      MimeMessage confirmationMessage = new MimeMessage( mailSession );

      confirmationMessage.setText( "Email body" );
      confirmationMessage.setSubject( "re: something important" );

      // TO and FROM addresses
      Address recipientAddress = new InternetAddress( "java@sun.com" );
      confirmationMessage.addRecipient( Message.RecipientType.TO, recipientAddress );
      confirmationMessage.setFrom( new InternetAddress( "blah@sun.com" ) );

      // send!
      Transport.send( confirmationMessage );

malloc will be first against the wall when the revolution comes...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline vrm

Junior Devvie




where I should sign ?


« Reply #3 - Posted 2004-03-17 12:06:25 »

Quote


? Can you download extra JAR's onto the phone ?

The version I usually use is about 350k in two jar files which you just drop into the directory (or preferably into your JVM's EXT directory) - which is probably way too big for you? Smiley


350k .. bloat bloat  Tongue
Offline davidaprice

Junior Devvie





« Reply #4 - Posted 2004-03-19 07:18:54 »

Sadly, with MIDP you can't just drop extra library JAR files into the phone. The platform (MIDP + optional APIs like JSR-120 SMS API) that the phone ships with is all you have: everything else must be included in the MIDlet's own JAR file.

The Nokia 6610 is a 'Series 40' phone, not a Symbian 'Series 60' phone. As such it has a MIDlet JAR file size restriction of 64KB, so Blah's Java Mail API JAR would be too big, even if it worked with the MIDP APIs (which it won't).

And the sample code that vrm posted is J2SE code, and uses J2SE's java.net API which is not available in MIDP. So that won't work either, sorry.

The Nokia 6610 supports MIDP 1.0, so the only networking protocol it supports is HTTP (client only). To write an e-mail MIDlet you'll have to connect over HTTP to a custom servlet (or CGI script, etc.), and write the custom servlet to use code like vrm's to access the real mail server.

MIDP 2.0 (supported in Nokia 5140, 6230, 6600, 6620,  7610, 7700, 9500)  optionally supports socket networking, and these Nokia implementations include this option.  It uses the CLDC 'Generic Connection Framework' rather than the J2SE java.net APIs, so the socket code for those phones will be slightly different to vrm's example J2SE code.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (49 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (105 views)
2014-11-26 15:20:36

toopeicgaming1999 (31 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!