Emailing Process?

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Emailing Process?

Postby john1598360627 » Thu Nov 23, 2023 12:42 am

I'm curious what the proper process for emailing is within Servoy.

I see that there is a mail plugin. This is how to send emails through Servoy right? An html email that can contain an attachment, such as a PDF.

Code: Select all
Send a mail, if you make the msgText start with the message will be sent in html (and you can use all html formatting).
If you want to have a different reply address than from, you can specify this with the from parameter by adding another email after it.
var attachment = plugins.mail.createBinaryAttachment('embedded',plugins.file.readFile('c:/temp/a_logo.gif'));
var msgText = 'plain msg<html>styled html msg<img src="%%embedded%%"></html>';
var success = plugins.mail.sendMail('to_someone@example.com,to_someone_else@example.net', 'John Cobb <from_me@example.com>', 'subject', msgText,null,'bcc1@example.com,bcc2@example.com',attachment);
if (!success)
{
   plugins.dialogs.showWarningDialog('Alert','Failed to send mail','OK');
}

@param {String} to A string containing 1 or multiple addresses separated by a comma.
@param {String} from A string containing an address and optional reply addresses, separated by commas.
@param {String} subject The subject of the mail
@param {String} msgText The message text
@param {String} cc One or more addresses separated by a comma
@param {String} bcc One or more addresses separated by a comma
@param {Attachment} attachment A single attachment

@return Boolean



QUESTIONS


1. If I understand correctly, we have to setup a Mail Server for the plugin to work right? After that is setup, sending emails out should work.

This is all fully supported within the new Servoy TiNG releases correct?

2. Also, how does Receiving emails work? Is that setup with the Mail Server as well? And user login can be used to see emails stored within the mail server?
Code: Select all
plugins.mail.receiveMail(username, password, leaveMsgsOnServer, receiveMode, onlyReceiveMsgWithSentDate, properties)


3. Is there any way of tracking to see if an email has successfully been received by the recipient? I'm not sure if that's an email protocol even possible, was just curious.


HELP
I'm just trying to make sure I fully understand the process. To put it simply, I want users to be able to send out emails that have PDF attachments. Seems straight forward... but I want to make sure I catch any problems due to my assumptions.
john1598360627
 
Posts: 175
Joined: Tue Aug 25, 2020 3:03 pm

Re: Emailing Process?

Postby mboegem » Fri Nov 24, 2023 12:26 pm

Hi John,

I don't think you should approach the 'proper way' from the Servoy point of view, but rather what does fit best for your use case.

So far I read that you simply want to send an email with PDF attachment.
This is easily done using the default mail plugin.
The email body can contain HTML, however you should keep in mind the limitations of that (which are not any different compared to other email composers)

Configuring the mail plugin can be done through the Servoy-admin page (server plugins), or dynamically from code.
As this is a Java plugin, all code will run on the server (for at least headless client and webclient/NG/TiNG). No constraints on support for TiNG here.

Considering your questions:
1) Yes, you need to setup an account (or use existing one) on an smtp server which you can use to send emails.
This is not any different from configuring a random email client on your computer.

2) I haven't used receiveMail from the default mail plugin.
Seems it is limited to fetching messages from a pop3 mailbox, so you will be looking at 1 specific mailbox, accessed by username, password on the pop3 host.

3) Although some email clients do offer the option to add a 'read request' to the email, it is not said that the receiving client will automatically respond to that and sometimes the receiving client will let the user decide whether or not to respond to the read request.
So doing it this way is definitely not a 100% solution
The question is what you are trying to resolve here:
a) people taking notice of your pdf? Maybe providing a download link to the pdf on your server instead of attaching it, is the solution.
This way you can make the PDF to be downloaded through an API, the API can recognise the request and link that to your user.
b) just tracking if the email is opened? Basically the same as previous solution but embed a 1px sized transparent image in your message which needs to be downloaded through an API.
Using a unique code in the download link can make you track a specific email.

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Emailing Process?

Postby john1598360627 » Wed Dec 06, 2023 2:59 am

mboegem wrote:Hi John,

I don't think you should approach the 'proper way' from the Servoy point of view, but rather what does fit best for your use case.

So far I read that you simply want to send an email with PDF attachment.
This is easily done using the default mail plugin.
The email body can contain HTML, however you should keep in mind the limitations of that (which are not any different compared to other email composers)

Configuring the mail plugin can be done through the Servoy-admin page (server plugins), or dynamically from code.
As this is a Java plugin, all code will run on the server (for at least headless client and webclient/NG/TiNG). No constraints on support for TiNG here.

Considering your questions:
1) Yes, you need to setup an account (or use existing one) on an smtp server which you can use to send emails.
This is not any different from configuring a random email client on your computer.

2) I haven't used receiveMail from the default mail plugin.
Seems it is limited to fetching messages from a pop3 mailbox, so you will be looking at 1 specific mailbox, accessed by username, password on the pop3 host.

3) Although some email clients do offer the option to add a 'read request' to the email, it is not said that the receiving client will automatically respond to that and sometimes the receiving client will let the user decide whether or not to respond to the read request.
So doing it this way is definitely not a 100% solution
The question is what you are trying to resolve here:
a) people taking notice of your pdf? Maybe providing a download link to the pdf on your server instead of attaching it, is the solution.
This way you can make the PDF to be downloaded through an API, the API can recognise the request and link that to your user.
b) just tracking if the email is opened? Basically the same as previous solution but embed a 1px sized transparent image in your message which needs to be downloaded through an API.
Using a unique code in the download link can make you track a specific email.

Hope this helps

Thank you for this breakdown! That seemed to answer everything thus far.

Once I'm able to tackle the email more I'll post any more questions I come into.
john1598360627
 
Posts: 175
Joined: Tue Aug 25, 2020 3:03 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 26 guests

cron