Changes for page Sending Emails
Last modified by Pascal Robert on 2012/08/12 21:24
From version 4.1
edited by smmccraw
on 2007/07/08 09:46
on 2007/07/08 09:46
Change comment:
There is no comment for this version
To version 8.1
edited by Pascal Robert
on 2010/09/19 10:25
on 2010/09/19 10:25
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Programming__WebObjects-Web Applications-Development-Sending Emails1 +Development-Sending Emails - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. smmccraw1 +XWiki.probert - Content
-
... ... @@ -1,8 +1,8 @@ 1 -== Overview 1 +== Overview == 2 2 3 3 Sending emails is a very common requirement in a web application. There are several methods you can choose from, each with varying levels of complexity and power. 4 4 5 -== JavaMail 5 +== JavaMail == 6 6 7 7 [[JavaMail>>http://java.sun.com/products/javamail/]] is Sun's API definition and open-source reference implementation of various methods of sending and receiving mail. All of the other WO mail-sending techniques are based on JavaMail, but you can choose to use it directly rather than use the higher level API's described below. If you would like to use JavaMail on your own, you will need to download and install the following jars and put them into your WOA's classpath: 8 8 ... ... @@ -9,32 +9,30 @@ 9 9 * [[JavaMail>>http://java.sun.com/products/javamail/downloads/index.html]] 10 10 * [[Java Activation Framework>>http://java.sun.com/products/javabeans/jaf/downloads/index.html]] 11 11 12 -== WOMailDelivery 12 +== WOMailDelivery == 13 13 14 14 Built into WebObjects is the WOMailDelivery class. It provides a very simple API for sending mails, but lacks the power of Project Wonder's version. To use WOMailDelivery, you will need to set your SMTP server in one of the following ways: 15 15 16 -* Add --DWOSMTPHost=smtp.yourmailserver as a launch parameter--16 +* Add DWOSMTPHost=smtp.yourmailserver as a launch parameter 17 17 * Set WOSMTPHost=smtp.yourmailserver.com in your Properties file 18 18 * Hardcode it with WOApplication.application().setSMTPHost("smtp.yourmailserver.com"); 19 19 20 20 Refer to the [[WOMailDelivery API>>http://developer.apple.com/documentation/WebObjects/Reference/API/com/webobjects/appserver/WOMailDelivery.html]] for more information, but to simply send an email, you can use the following command: 21 21 22 -{{ panel}}22 +{{code}} 23 23 24 - 25 - 26 - 27 - 28 - 29 - 30 - 24 +WOMailDelivery.sharedInstance().composePlainTextEmail( 25 + fromAddress, 26 + toAddresses, 27 + bccAddresses, 28 + subject, 29 + body, 30 + WOMailDelivery.SEND_NOW ); 31 31 32 -{{/ panel}}32 +{{/code}} 33 33 34 34 By default, WOMailDelivery with use Sun's old SMTP implementation. However, if you install JavaMail (as described above) into your WOA or /Library/WebObjects/Extensions, WOMailDelivery will use it instead. 35 35 36 -== ERJavaMail 36 +== ERJavaMail == 37 37 38 -ERJavaMail is part of Project Wonder and provides an API for sending component-based emails. ERJavaMail also uses the JavaMail API's underneath, but it includes the jars inside its framework, so you don't need to manually install JavaMail to use it. Because it does not have any external dependencies on other Project Wonder frameworks, you can use it without bringing in any other Project Wonder frameworks. For more information on ERJavaMail, see the [[ERJavaMail>>Programming__WebObjects-Project WONDER-Frameworks-ERJavaMail]] page. 39 - 40 -Category:WebObjects 38 +ERJavaMail is part of Project Wonder and provides an API for sending component-based emails. ERJavaMail also uses the JavaMail API's underneath, but it includes the jars inside its framework, so you don't need to manually install JavaMail to use it. Because it does not have any external dependencies on other Project Wonder frameworks, you can use it without bringing in any other Project Wonder frameworks. For more information on ERJavaMail, see the [[ERJavaMail>>Project WONDER-Frameworks-ERJavaMail]] page.