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 buyermail { //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 = "pourli@verizon.net"; static final String user = "pourli"; static final String pass = "children231"; public static void main(String[] 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 fname = argv[1].replace('+',' '); String lname = argv[2].replace('+',' '); String quantity = argv[3].replace('+',' '); String iname = argv[4].replace('+',' '); String timestamp = argv[5].replace('+',' '); String total = argv[6].replace('+',' '); String line1 = "Dear " + fname + " " + lname + ",\n\n"; String line2 = "Thank you for your purchase of " + quantity + " " + iname + " on " + timestamp + ".\n\n"; String line3 = "Please send a check in the amount of " + total + " to the following:\n\n"; String line4 = "\tPayee name: \n\n"; String line5 = "\tPayee address: \n\n"; sb.append(line1); sb.append(line2); sb.append(line3); sb.append(line4); sb.append(line5); //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); } } }