ورود

View Full Version : ارسال ایمیل با اهراز هویت در جاوا



mazy12
دوشنبه 11 شهریور 1387, 12:14 عصر
سلام، کد ارسال ایمیل از طریق smtp سرور رو دارم اما می خوام اهراز هویت بشم . لطفا کمک کنید؟


os.writeBytes("HELO\r\n");
// You will add the email address that the server
// you are using know you as.
os.writeBytes("MAIL From: <you@yourcompany.com>\r\n");

// Who the email is going to.
os.writeBytes("RCPT To: <theperson@theircompany.com>\r\n");
//IF you want to send a CC then you will have to add this
os.writeBytes("RCPT Cc: <theCC@anycompany.com>\r\n");


// Now we are ready to add the message and the
// header of the email to be sent out.
os.writeBytes("DATA\r\n");

os.writeBytes("X-Mailer: Via Java\r\n");
os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n");
os.writeBytes("From: Me <me@mycompany.com>\r\n");
os.writeBytes("To: YOU <you@yourcompany.com>\r\n");

//Again if you want to send a CC then add this.
os.writeBytes("Cc: CCDUDE <CCPerson@theircompany.com>\r\n");

//Here you can now add a BCC to the message as well
os.writeBytes("RCPT Bcc: BCCDude<BCC@invisiblecompany.com>\r\n");
}

sMessage = "Your subjectline.";

os.writeBytes("Subject: Your subjectline here\r\n");
os.writeBytes(sMessage + "\r\n");
os.writeBytes("\r\n.\r\n");
os.writeBytes("QUIT\r\n");