Changing the reply address of a sent mail

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

Changing the reply address of a sent mail

Postby mees » Mon Nov 23, 2020 9:24 am

Hello all,

We are using the mails plugin to send messages from our application. This is done from a noreply-address. However, since we want to give the recipient of the message the opportunity to reply quickly, I want to change the reply address that is attached to the mail.
This can be done by using the 'send on behalf of'-feature, which I want to implement. However, for some reason I can't seem to get it to work. As far as I was able to find, it should be done by setting the following override property:

overrideProperties.push('mail.smtp.from=mees@cervus.nl');

And then use the noreply-address as the from-address in the actual plugins.mail.sendMail-call.

When I send the message to myself like that, I can see that the message was sent from the noreply-address VIA the @cervus.nl-address. But the reply address is still the noreply.

Can anyone maybe help me with this? What properties should I set in order to achieve what I want?

Thanks in advance!
mees
 
Posts: 6
Joined: Fri Dec 28, 2018 3:53 pm

Re: Changing the reply address of a sent mail

Postby swingman » Mon Nov 23, 2020 10:35 am

Hi, have to tried this?
Code: Select all
/** @type {Array<String>} */
var extra_properties = [];
extra_properties.push("replyto.address=" + reply_to);


and then something like this:

Code: Select all
var success = plugins.mail.sendMail(to, from, subject, msg, cc, null, attachments, extra_properties);


I also use this extra_properties array to authenticate against Office365.

Hope this helps,
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1374
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Changing the reply address of a sent mail

Postby mees » Mon Nov 23, 2020 1:15 pm

Hey Christian, thanks for the reply!

The method currently looks like this:
var overrideProperties = new Array();

//Some other overrideProperties here, such as ssl protocols and such

success = plugins.mail.sendMail(record.email,noReplyAddress,record.subject,record.body,cc,record.bccemail, attachments, overrideProperties);

When i add the line
overrideProperties.push('replyto.address=test@cervus.nl');

nothing changes, unfortunately - I'm adding it before the sendMail-command, of course. When I send the mail to myself and press reply, it still wants to send the reply to the noreply-address. Am I implementing it wrongly?
mees
 
Posts: 6
Joined: Fri Dec 28, 2018 3:53 pm

Re: Changing the reply address of a sent mail

Postby ROCLASI » Mon Nov 23, 2020 1:58 pm

Hi Mees,

I don't think replyTo is a property you can set. It's a function call in the mail api.
So I think it has to be exposed in the plugin to be able to use.

Here is a link with all the mail.smtp.* properties:
https://javaee.github.io/javamail/docs/ ... mmary.html
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5385
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Changing the reply address of a sent mail

Postby swingman » Mon Nov 23, 2020 2:08 pm

I now remember this was causing me a lot of problems...

There may be another way round this, but I have not tried this. Some email services, also allow you to send email via a REST-api.
If I remember right, Office365 has this option. You may be able to set the reply-to this way...
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1374
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Changing the reply address of a sent mail

Postby mees » Mon Nov 23, 2020 2:53 pm

Hm... Maybe it's best to ask Servoy to expose such a function in their mail plugin then. If it's a function call, they should be able to do so.

Thanks for the help!
mees
 
Posts: 6
Joined: Fri Dec 28, 2018 3:53 pm

Re: Changing the reply address of a sent mail

Postby robert.edelmann » Tue Nov 24, 2020 8:31 pm

We're using "MailPro plugin for Servoy" from here: http://www.servoy-plugins.de/plugins/mailpro/mailpro-plugin.html
The plugin exposes the replyto-address as a property of your new mail:

var mailMessage = smtpAccount.createMessage();
mailMessage.setCharset('UTF-8');
mailMessage.fromAddresses = plugins.MailPro.EmailAddress('noreply@address.com');
mailMessage.addRecipient(plugins.MailPro.EmailAddress('recipient@address.com'), 'TO');
mailMessage.replyTo = plugins.MailPro.EmailAddress('reply@address.com');
mailMessage.subject = subject;
mailMessage.plainMsg = body;
mailMessage.setMessageContent();
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 18
Joined: Wed Aug 14, 2013 6:12 pm

Re: Changing the reply address of a sent mail

Postby mees » Mon Dec 21, 2020 9:40 am

Thanks for the suggestion Robert, however, since we've already written the entire mail scope for our application, I'd hate to have to rewrite it all with a plugin.

I've made a ticket for it:
https://support.servoy.com/browse/SVY-15688
mees
 
Posts: 6
Joined: Fri Dec 28, 2018 3:53 pm

Re: Changing the reply address of a sent mail

Postby lvostinar » Mon Jan 11, 2021 3:51 pm

mees wrote:Hm... Maybe it's best to ask Servoy to expose such a function in their mail plugin then. If it's a function call, they should be able to do so.

Thanks for the help!


We already have this feature, the reply-to address can be specified in the from parameter, after the real from. I improved the docs so this is more visible.
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1053
Joined: Tue Feb 19, 2008 10:53 am


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 5 guests

cron