Sending email notification from Servoy forms to the client

Hi all,

I have the following method that suppose to send email to the users:

//globals.tx3 gets populated with the users email address
var user = globals.tx3

// task_name projects task name
var msgText = task_name

// project_description
var projdsc = project_description

// Projects comments
var comm = comments

var succes = plugins.mail.sendMail(‘user ,to_someone_else@testing.com’, ‘From Servoy XMLR Projectabk@stanford.edu’, ‘XMRL project has been assigned to you’, msgText + projdsc,null,‘unnamed@testing.com’);
if (!succes)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send mail’,‘OK’);
}

The globals.tx3 gets updated with the user’s email address.
When I replace the email address with the variable user in var succes = plugins.mail.sendMail(‘user ,to_someone_else@testing.com’, servoy errors out.

Please let me know how I can fix this.

Thanks for any help.

Abrahim

Try this:

var succes = plugins.mail.sendMail(user ,'to_someone_else@testing.com', 'From Servoy XMLR Project<abk@stanford.edu>', 'XMRL project has been assigned to you', msgText + projdsc,null,'unnamed@testing.com'); 
if (!succes) 
{ 
plugins.dialogs.showWarningDialog('Alert','Failed to send mail','OK'); 
}

Harjo,

I tried :

var user = globals.tx3

// task_name projects task name
var msgText = task_name

// project_description
var projdsc = project_description

// Projects comments
var comm = comments
var succes = plugins.mail.sendMail(user ,‘to_someone_else@testing.com’, ‘From Servoy XMLR Projectabk@stanford.edu’, ‘XMRL project has been assigned to you’, msgText + projdsc,null,‘unnamed@testing.com’);
if (!succes)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send mail’,‘OK’);
}

But I get error:

“Falied to send mail”

Please let me know where is the problem.

Thanks for the help,

Abrahim

Make sure you have your mail plug-in settings correct. Go into preferences on the mail tab to set your server - then go into the SERVER (http://yourip:port/servoy-admin) and look on the main page for any authentication information that you may need to provide.

Bob,

The mail plug-in is working fine.
If I replace user with abk@stanford.edu, then Servoy will send the email fine.

If I change:

var succes = plugins.mail.sendMail(user, ‘abk@stanford.edu’, ‘From Servoy XMLR Projectabk@stanford.edu’, ‘XMRL project has been assigned to you’, msgText + projdsc,null,‘abk@stanford.edu’);
if (!succes)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send mail’,‘OK’);
}

To:

var succes = plugins.mail.sendMail(‘abk@stanford.edu, abk@stanford.edu’, ‘From Servoy XMLR Projectabk@stanford.edu’, ‘XMRL project has been assigned to you’, msgText + projdsc,null,‘abk@stanford.edu’);
if (!succes)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send mail’,‘OK’);
}

Then, it works fine, but I need to use “user”. Why? Because that filed gets updated with different email address each time users create a new record.
Please let me know if there is a better way to deal with this.

Thanks in advance,

Abrahim

I think this is your problem:

'abk@stanford.edu, abk@stanford.edu'

is not equal to ```
user, ‘abk@stanford.edu’


What you should put in there is:

user+‘, abk@stanford.edu’


Paul

Paul,

Your solution fixed the problem.

Thank you so much!

Abrahim

I use

var from =  bedrijf_voorkeuren.email_werk ;
var subject = titel ;
var msgText = omschrijving ;
var version = globals.gVersion ;


var succes = plugins.mail.sendMail('info@freecolours.com', from, version + subject, msgText,null,null); 
if (!succes) 
{ 
plugins.dialogs.showWarningDialog('Alert','Failed to send mail','OK'); 
}

But the server gives me this error:

SMTPSend javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.MessagingException: 553 testbedrijf.nl does not exist

The actual e-mailaddress is info@testbedrijf.nl, so it misses the ‘info@’…
I guess there is something wrong with the ‘from’ code?

It means your MTA (Mail Transfer Agent) returned a 553 code with the message “testbedrijf.nl does not exist”.

I checked and that domain indeed doesn’t resolve to an IP so your mailserver (MTA) can’t connect to their mailserver to deliver the mail.

Hope this helps.

ROCLASI:
It means your MTA (Mail Transfer Agent) returned a 553 code with the message “testbedrijf.nl does not exist”.

I checked and that domain indeed doesn’t resolve to an IP so your mailserver (MTA) can’t connect to their mailserver to deliver the mail.

Hope this helps.

It did! Thanks ROCLASI, I changed the e-mail adress and it works smoothly :D