• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

help with SMTP CC

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to 'other Java APIs' ...
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic