Friday, March 17 2006

Sending email messages

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.

import puakma.system.*;

/**
* Called to send email
*/
public class SendMail extends ActionRunner
{

public String execute()
{

Document doc = new Document(pSystem, pSession.getSessionContext());
doc.replaceItem("From", "info@puakma.net");
doc.replaceItem("Subject", "Important Email");
doc.replaceItem("SendTo", "user1@email.address");
doc.replaceItem("CopyTo", "user2@email.address"); //optional
doc.replaceItem("BlindCopyTo", "user3@email.address"); //optional

doc.replaceItem("Body", "The message goes here and may be HTML format...");

 
//optional
doc.replaceItem("Importance", "1"); //set as high importance, arrives with a !
doc.replaceItem("ReturnReceipt", "1"); //attach a return receipt

doc.send();

return ""; //return an empty string to denote no redirect
}


}//class

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.

Recent Comments

Fphcba yitxuuhgenka, [url=http://nfqsfrsjzczl.com/]nfqsfrsjzczl[/url], [link=http://lwacvvvrmmyl.com/]lwacvvvrmmyl[/link], http://lbrjxmihcvaq.com/
Posted by lrqfgb at xdbncb.com   on   07.May.09 06:25
; health insurance >:); life insurance quotes hjcwb; home insurance 680; mortgage rates 718652; auto insurance 550; marlboro =O;
Posted by scuko355 at scuk.pl   on   13.May.09 22:22
This will allow better blood flow to your lower limbs and to your groin area.; ambien rgw; phentermine wjfzyk; levitra lyb; viagra :OO; tamiflu znuth;
Posted by scuko63 at scuk.pl   on   22.May.09 03:08
If you proceed to buy Viagra online try to raise this type of questions with your online sources.; prednisone %[; xanax lgluiw; ambien 3199; generic viagra mqlx; tramadol %DD;
Posted by scuko56 at scuk.pl   on   22.May.09 03:08
The study funded by Schwarz Pharma Inc. used alprazolam Niravam oral disintegrating tablets a benzodiazepine made by Schwarz.; phentermine afm; buy viagra :]; levitra 313; cialis 193392;
Posted by scuko173 at scuk.pl   on   22.May.09 06:14
Show all comments
Got something to say? Add comment