javamail - mail is sent successfully or not by java mail api -
i have written below program send mail through java mail api send mail query handle exceptional scenarios lets if mail not sent have da , if mail send have other thing in cas , please advise java mail api proved parameter while sending mail buy can check mail been sent or not have enabled debugging in program
emailsession.setdebug(true);
please advise parameter in return sent java mail api can check mail sent or not
below simple program of java mail api
public class emailtest { public static void main(string[] args) { string mailsmtphost = "cakelycakes.com"; string mailto = "bigcakes@cakelycakes.com"; string mailcc = "littlecakes@cakelycakes.com"; string mailfrom = "me@here.there.everywhere"; string mailsubject = "email java"; string mailtext = "this email java"; sendemail(mailto, mailcc, mailfrom, mailsubject, mailtext, mailsmtphost); } public static void sendemail(string to, string cc, string from, string subject, string text, string smtphost) { try { properties properties = new properties(); properties.put("mail.smtp.host", smtphost); session emailsession = session.getdefaultinstance(properties); message emailmessage = new mimemessage(emailsession); emailmessage.addrecipient(message.recipienttype.to, new internetaddress(to)); emailmessage.addrecipient(message.recipienttype.cc, new internetaddress(cc)); emailmessage.setfrom(new internetaddress(from)); emailmessage.setsubject(subject); emailmessage.settext(text); emailsession.setdebug(true); transport.send(emailmessage); } catch (addressexception e) { e.printstacktrace(); } catch (messagingexception e) { e.printstacktrace(); } } }
i think you're looking these javamail faq entries:
Comments
Post a Comment