import java.io.*; import java.util.Properties; // import javax.servlet.*; // import javax.servlet.http.*; import javax.mail.*; import javax.mail.internet.*; import com.sun.mail.smtp.*; public class mastermail { //please feel these fields with your data //static final String ToAddress = "plee1143@cyberspace.org"; static final String host = "outgoing.verizon.net"; //SMTP host //static final String from = argv[1]; //second argv static final String user = "pourli"; static final String pass = "children231"; public static void main(String[] argv){ final String from = argv[1]; //second argv try { //initialize the StringBuffer object within the try/catch loop StringBuffer sb = new StringBuffer( ); //Get system properties Properties props = System.getProperties( ); //Setup mail server props.put("mail.smtp.host", host); props.put("mail.debug", "false"); props.put("mail.smtp.auth","true"); //Get session Session session = Session.getDefaultInstance(props, null); session.setDebug(false); session.setPasswordAuthentication(new URLName("smtp",host,25,"INBOX",user,pass), new PasswordAuthentication(user,pass)); //Define message MimeMessage msg = new MimeMessage(session); //Set the from address msg.setFrom(new InternetAddress(from)); //Set the to address msg.addRecipient(Message.RecipientType.TO, new InternetAddress(argv[0])); //Set the subject msg.setSubject("Shoppers' World using JavaMail APIs"); //Set the text content for body String body = argv[2].replace('+',' '); body = body.replace('\n','\n'); String line1 = body + " \n\n"; sb.append(line1); //sb.append("This is the 2nd String line.\n\n"); //sb.append("This is the 3rd String line.\n\n"); /* int i=1; while (!argv[i].equals("END")) { System.out.print(argv[i]); String s = argv[i] + " "; sb.append(s); i++; } System.out.print(sb.toString( )); */ //sb.append(argv[1]); msg.setText(sb.toString( )); //msg.setText(argv[1]); //Send message Transport tr = session.getTransport("smtp"); tr.connect(host, user, pass); msg.saveChanges(); // don't forget this tr.sendMessage(msg, msg.getAllRecipients()); tr.close(); } catch (MessagingException e) { System.out.println(e); } } }