• Post Reply Bookmark Topic Watch Topic
  • New Topic

help with SMTP CC  RSS feed

 
Philip Pross
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm learning javamail, and I came to this code I found.

import sun.net.smtp.SmtpClient;
import java.io.PrintStream;
public class SmtpClientExample {
public static void main (String args[])
throws Exception {
String host = args[0];
String from = args[1];
String to = args[2];
SmtpClient smtp = new SmtpClient(host);
smtp.from(from);
smtp.to(to);
PrintStream msg = smtp.startMessage();
msg.println("To: " + to);
msg.println("Subject: Hello SmtpClient");

msg.println();
msg.println("This is a test message.1");
msg.println("This is a test message.2");
msg.println("This is a test message.3");
msg.println("This is a test message.4");
msg.println("This is a test message.5");
msg.println("This is a test message.6");
smtp.closeServer();
}
}
I'm wondering if its possible to also send to a "CC", or do I send it twice
For now, I want to learn how to send maill without the javamail api, just to learn the basics.
Thanks
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to 'other Java APIs' ...
 
Lewin Chan
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hej,
The simple answer is that sun.net.smtp.SmtpClient doesn't support CC
Judging by the decompiled code, the client code itself simply makes a socket connection to the specified server and issues the usual SMTP commands to it.
It looks as though you could probably extend it so that you could add CC's and BCC's pretty easily. The logic of doing that and not using the javamail api escapes me at this time.
L
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!