I need to send emails over the Gmail SMTP server (smtp.gmail.com)
I checked the requirements to send email using gmail smtp server which are as follows:
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587
Account Name: your full email address (including @gmail.com or @your_domain.com)
Email Address: your email address (username@gmail.com or username@your_domain.com)
Password: your Gmail password
I checked the http://java.sun.com/products/javamail/j … mmary.html to build the array
var properties = new Array()
properties[0] = ‘mail.smtp.host=smtp.gmail.com’
properties[1] = ‘mail.smtp.port=465’
properties[2] = ‘mail.smtp.auth=true’
properties[3] = ‘mail.smtp.starttls.enable=true’
properties[4] = ‘mail.smtp.user=james.dcunha@gmail.com’
Its throwing me errors when i use the above as my properties array.
what would be the key to enter for password and do I need to add any values in the properties array?
Down below is the code:
var properties = new Array()
properties[0] = ‘mail.smtp.host=smtp.gmail.com’
properties[1] = ‘mail.smtp.port=465’
properties[2] = ‘mail.smtp.auth=true’
properties[3] = ‘mail.smtp.starttls.enable=true’
properties[4] = ‘mail.smtp.user=john.doe@gmail.com’
var msgText = ‘test message’;
var success = plugins.mail.sendMail(‘john.doe@gmail.com’, ‘johndoe@hotmail.com’, ‘subject’, msgText,null,null,properties);
if (!success)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send mail’,‘OK’);
}
var msgText = ‘test message’;
var success = plugins.mail.sendMail(‘john.doe@hotmail.com’, ‘john.doe@gmail.com’, ‘subject’, msgText,null,null,properties);
if (!success)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send mail’,‘OK’);
}
But it didn’t work. Just wanted to share this information with you. Any ideas on the correct way to build the properties array for SSL.
I tried the following but it didn’t work, I thought the issue could be a port number so i changed it to 465 and it didn’t work. I checked the server log files
org.mozilla.javascript.WrappedException: Wrapped java.lang.ArrayStoreException (C:\Documents and Settings\Servoy\servoy_workspace\dennis\globals.js#725) at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1828) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:199) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:347) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3666) at script.send_mail_test(C:\Documents and Settings\Servoy\servoy_workspace\dennis\globals.js:725) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3122) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165) at com.servoy.j2db.scripting.RemoteDebugScriptEngine.executeFunction(RemoteDebugScriptEngine.java:109) at com.servoy.j2db.scripting.ScriptMenuItem$1.run(ScriptMenuItem.java:9) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at com.servoy.extensions.plugins.mail.MailProvider.js_sendMail(MailProvider.java:227) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179) … 17 more
My revised script is as follows:
function send_mail_test()
{
var properties = new Array();
properties[0] = 'mail.smtp.host=smtp.gmail.com';
properties[1] = 'mail.smtp.auth=true';
properties[2] = 'mail.smtp.starttls.enable=true';
properties[3] = 'mail.smtp.port=465';
properties[4] = 'mail.smtp.username=<<MY EMAIL ADDRESS>>';
properties[5] = 'mail.smtp.password=<<MY PASSWORD>>';
var msgText = 'test message';
var success = plugins.mail.sendMail('james.dcunha@gmail.com', 'jamesd_cunha@hotmail.com', 'subject', msgText,null,null,properties);
if (!success)
{
plugins.dialogs.showWarningDialog('Alert','Failed to send mail','OK');
}
}
I changed the port to 587 and it didn’t work either.
I might have to check the plugin source code to see where could be the issue. But any help would be appreciated
It seems to me I have declared and set the properties array correctly.
I will again investigate the code. But a second set of eyes always helps.
function send_mail_test()
{
//it is possbile to set all kind of smtp properties
var properties = new Array();
properties[0] = 'mail.smtp.host=smtp.gmail.com';
properties[1] = 'mail.smtp.auth=true';
properties[2] = 'mail.smtp.starttls.enable=true';
properties[3] = 'mail.smtp.port=465';
properties[4] = 'mail.smtp.username=james.dcunha@gmail.com';
properties[5] = 'mail.smtp.password=notmyrealpassword';
var msgText = 'test message';
var success = plugins.mail.sendMail('jamesd_cunha@hotmail.com', 'james.dcunha@gmail.com', 'subject', msgText,null,null,properties); //this corresponds to line 725
if (!success)
{
plugins.dialogs.showWarningDialog('Alert','Failed to send mail','OK');
}
}
The interesting this I noticed is on executing line 725 the function terminates and doesn’t proceed ahead with the if(!success) control block.
Hi guys,
I know this thread is from a while back, but it seems like the closest ot my issue…
I have a client that needs to do emailing thru an SMTP server that requires TLS encryption (not SSL).
Do I need to create a (self-signed?) certificate?
If so, where/how would I store that certificate so that the mail plugin will use it when I say
‘mail.smtp.starttls.enable=true’
I have been trying to do test email thru gmail as detailed here, but it’s not working currently (I think the IT dept. may have blocked port 587 for some reason and am waiting to hear back from them…)
Any help (on TLS certification) would be greatly appreciated.