Skip to main content

I built an email app but email received has To: undisclosed-recipients:

No replies
lse123
Offline
Joined: 2008-10-12
Points: 0

I built an email simple only send , app
using code like below but email received has To: undisclosed-recipients:

not the inserted real email well, what other way exist to send email in Java SE with To, the actual To field contents?

88. public void sendMail()
89. {
90. try
91. {
92. Socket s = new Socket(smtpServer.getText(), 25);
93.
94. InputStream inStream = s.getInputStream();
95. OutputStream outStream = s.getOutputStream();
96.
97. in = new Scanner(inStream);
98. out = new PrintWriter(outStream, true /* autoFlush */);
99.
100. String hostName = InetAddress.getLocalHost().getHostName();
101.
102. receive();
103. send("HELO " + hostName);
104. receive();
105. send("MAIL FROM: <" + from.getText() + ">");
106. receive();
107. send("RCPT TO: <" + to.getText() + ">");
108. receive();
109. send("DATA");
110. receive();
111. send(message.getText());
112. send(".");
113. receive();
114. s.close();
115. }
116. catch (IOException e)
117. {
118. comm.append("Error: " + e);
119. }
120. }
121.
122. /**
123. * Sends a string to the socket and echoes it in the comm text area.
124. * @param s the string to send.
125. */
126. public void send(String s) throws IOException
127. {
128. comm.append(s);
129. comm.append("\n");
130. out.print(s.replaceAll("\n", "\r\n"));
131. out.print("\r\n");
132. out.flush();
133. }
134.
135. /**
136. * Receives a string from the socket and displays it in the comm text area.
137. */
138. public void receive() throws IOException
139. {
140. String line = in.nextLine();
141. comm.append(line);
142. comm.append("\n");
143. }