How to send an email from your application
Puakma supports the easy sending of outbound SMTP mail. To mail enable an Action, all you need is to call the Document's send() method. Calling this method puts the mail in the outbound mail queue to be physically sent by the MAILER server addin task. Following is the basic skeleton for sending an email.
* Called to send email
public class SendMail extends ActionRunner
public String execute()
Document doc = new Document(pSystem, pSession.getSessionContext());
doc.replaceItem("Subject", "Important Email");
doc.replaceItem("CopyTo", "firstname.lastname@example.org"); //optional
doc.replaceItem("BlindCopyTo", "email@example.com"); //optional
doc.replaceItem("Body", "The message goes here and may be HTML format...");
doc.replaceItem("Importance", "1"); //set as high importance, arrives with a !
doc.replaceItem("ReturnReceipt", "1"); //attach a return receipt
return ""; //return an empty string to denote no redirect
You can easily attach files by creating a new DocumentFileItem(...) on the Document. Each file will be sent as an email attachment.
Multiple recipients are catered for by creating a DocumentMultiItem which may contain multiple recipient values. Use this for the SendTo, CopyTo and BlindCopyTo fields if required.
The call to the send() method returns immediately as the message is queued. Ensure you have a MAILER running against the Puakma database, as this is when the email will be physically transmitted to the recipient's SMTP mail host (see the /puakma/config/puakma.config file for MAILER settings). You can also check the server log in http://your_server/system/admin.pma to see if the mail has been successfully sent.