sendMail and Notification

Questions and answers on developing, deploying and using plugins and JavaBeans

sendMail and Notification

Postby stefaniacolombara » Thu Nov 20, 2014 11:05 am

I use the plugins.mail.sendMail but I don't find how to have a reply when the recipient has read it.
Does somebody know the solution ?
Thanks a lot!
Stefania
stefaniacolombara
 
Posts: 40
Joined: Mon Feb 06, 2012 11:19 am

Re: sendMail and Notification

Postby mboegem » Thu Nov 20, 2014 12:00 pm

Hi Stefania,

the mail plugin is a wrapper for the javamail API.
As far as I can see there is some support for notification requests, but to use this you'll need an additional library.
I don't know if this is well-handled by the Servoy plugin.

Also keep in mind that a read confirmation is really a client-side action.
The recipient of the email can:
- deny to send the confirmation
- turn it off by default (for the whole email client)
- use a mail client that doesn't even support it (ie. Apple Mail doesn't have this option)

What I'm trying to say here is that you can't depend on a confirmation in your software.
The best option might be to request a delivery notification, which is handled between mail servers.
But also this notification needs the additional library.

Although I can't offer you a solution to your problem, I hope this will give you some input for additional thoughts on this subject.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

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

Re: sendMail and Notification

Postby ryanparrish » Thu Nov 20, 2014 2:00 pm

Marc is correct that it entirely relies on the recipient client to send the MDN back (and really in practice it's just outlook), however it doesn't require any additional libraries from the sender, you just need to add the "Disposition-Notification-To" header when sending the email.

https://tools.ietf.org/html/rfc3798#section-2.1
ryanparrish
 
Posts: 162
Joined: Thu May 17, 2007 7:49 pm
Location: Miami, FL

Re: sendMail and Notification

Postby stefaniacolombara » Thu Nov 20, 2014 3:23 pm

How I can add this header with the Servoy mail plugin?
Now I call the plugin in this mode:
plugins.mail.sendMail(mittente, indirizzo_da, _mailOggetto, _txtmsg, null, indirizzo_da, attachment1, properties)

where the properties is a array:
properties.push('mail.smtp.host=' + host_da); // smtp.gmail.com
if (requiresauthentication == 1 || requiresauthentication == true)
properties.push('mail.smtp.auth=true');
else
properties.push('mail.smtp.auth=false');
properties.push('mail.smtp.username=' + userName);
if (useTLS == 1 || useTLS == true)
properties.push('mail.smtp.starttls.enable=true');
else
properties.push('mail.smtp.starttls.enable=false');
properties.push('mail.smtp.port=' + porta); // es.587 o 465
properties.push('mail.smtp.password=' + passw);
properties.push('mail.smtp.connectiontimeout=' + timeOut)
properties.push('mail.smtp.timeout=' + timeOut)
if (useSSL == 1 || useSSL == true)
properties.push('mail.smtp.ssl.enable=true');
else
properties.push('mail.smtp.ssl.enable=false');

Thanks a lot!
Stefania
stefaniacolombara
 
Posts: 40
Joined: Mon Feb 06, 2012 11:19 am

Re: sendMail and Notification

Postby ryanparrish » Thu Nov 20, 2014 5:14 pm

Well, now I feel silly.
I've been using the MailPro plugin (http://servoy-plugins.de/plugins/mailpr ... lugin.html) for so long now I thought it was the default servoy mail plugin. The default mail plugin doesn't have the ability to add arbitrary headers to a mail message, like the one we've been discussing. However the MailPro plugin does have this capability, and much more. I'd recommend checking out the MailPro plugin, it's free so you don't really have anything to lose.
ryanparrish
 
Posts: 162
Joined: Thu May 17, 2007 7:49 pm
Location: Miami, FL

Re: sendMail and Notification

Postby Harjo » Thu Nov 20, 2014 6:05 pm

There is main difference between mail en mailPro plugin. (despite of the features)
In case of smart-client, the mail plugin of Servoy is sending the mail serverside! so hostnames are resolved serverside, and the mail is really send from the server. not the smart-client.
In case of the mailPro plugin, it sends the mail, client-side. If you want the mailPro todo that also, use it in a headless client.

In case of webclient, there is no difference, because server and client, are already serverside.
Harjo Kompagnie
byKom B.V.
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: sendMail and Notification

Postby stefaniacolombara » Thu Nov 20, 2014 6:51 pm

Hi Ryanparrish,
I have installed the plugin MailPro but I don't find a example on how to add the header for the notification, could you please show me how you set it?
Thanks a lot!
Stefania
stefaniacolombara
 
Posts: 40
Joined: Mon Feb 06, 2012 11:19 am

Re: sendMail and Notification

Postby ryanparrish » Thu Nov 20, 2014 7:14 pm

Code: Select all
var vSmtp = plugins.MailPro.SMTPAccount();
if (application.isInDeveloper()) {
       vSmtp.host = 'localhost';
       vSmtp.userName = null;
       vSmtp.password = null;
       vSmtp.requiresAuthentication = false;
} else {       
       //Production
       vSmtp.host = 'smtp.example.com';
       vSmtp.userName = "postmaster@example.com";
       vSmtp.password = "XXXXXXX";
       vSmtp.requiresAuthentication = true;
       vSmtp.useTLS = true;
}

var vSuccess = vSmtp.connect();
if (vSuccess === false) {
   throw new Error("failed to connect to email server");
}
var message = vSmtp.createMessage();
message.addRecipient("someone@example.com","TO");
message.fromAddresses = "postmaster@example.com";
message.subject = "A subject";
message.plainMsg = "The plain message body";
message.addHeader("Disposition-Notification-To", "postmaster@example.com");  // <-----------
vSmtp.sendMessage(message);

ryanparrish
 
Posts: 162
Joined: Thu May 17, 2007 7:49 pm
Location: Miami, FL

Re: sendMail and Notification

Postby stefaniacolombara » Mon Nov 24, 2014 1:29 pm

Thanks a lot!
Stefania
stefaniacolombara
 
Posts: 40
Joined: Mon Feb 06, 2012 11:19 am


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 1 guest

cron