Propertiesprops=newProperties();Sessionsession=Session.getDefaultInstance(props,null);try{Messagemsg=newMimeMessage(session);msg.setFrom(newInternetAddress("admin@example.com","Example.com Admin"));msg.addRecipient(Message.RecipientType.TO,newInternetAddress("user@example.com","Mr. User"));msg.setSubject("Your Example.com account has been activated");msg.setText("This is a test");Transport.send(msg);}catch(AddressExceptione){// ...}catch(MessagingExceptione){// ...}catch(UnsupportedEncodingExceptione){// ...}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-20。"],[[["\u003cp\u003eThe Java Mail service API supports the \u003ccode\u003ejavax.mail\u003c/code\u003e interface for sending email messages within first-generation runtimes, with migration options for second-generation runtimes.\u003c/p\u003e\n"],["\u003cp\u003eTo send emails, you need to create a JavaMail \u003ccode\u003eSession\u003c/code\u003e object and a \u003ccode\u003eMimeMessage\u003c/code\u003e object, and configure the sender and recipients using the \u003ccode\u003eInternetAddress\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine can use its own Mail service for sending messages if no SMTP server is configured, but it also supports third-party providers like Mailgun, Mailjet, and SendGrid.\u003c/p\u003e\n"],["\u003cp\u003eYou can send multi-part messages, including file attachments and messages with both plaintext and HTML bodies, by using \u003ccode\u003eMimeMultipart\u003c/code\u003e and \u003ccode\u003eMimeBodyPart\u003c/code\u003e objects.\u003c/p\u003e\n"],["\u003cp\u003eThe Mail service handles contacting recipients' mail servers and delivering messages asynchronously, with error messages or bounces going to the sender.\u003c/p\u003e\n"]]],[],null,[]]