Page 1 of 1

sendMail and Notification

PostPosted: Thu Nov 20, 2014 11:05 am
by stefaniacolombara
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

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 12:00 pm
by mboegem
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.

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 2:00 pm
by ryanparrish
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

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 3:23 pm
by stefaniacolombara
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

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 5:14 pm
by ryanparrish
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.

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 6:05 pm
by Harjo
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.

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 6:51 pm
by stefaniacolombara
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

Re: sendMail and Notification

PostPosted: Thu Nov 20, 2014 7:14 pm
by ryanparrish
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);


Re: sendMail and Notification

PostPosted: Mon Nov 24, 2014 1:29 pm
by stefaniacolombara
Thanks a lot!
Stefania