Jump to content
Server Maintenance This Week. ×

Sending eMails with ScriptMaster


This topic is 3348 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Sending eMails (with or without attachments)

~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~

Unfortunately I'm not very familiar with Java and possibly am missing only two additional lines.

Basically every SMTP server today requires authentification for good reason - all of us receive far enough of SPAM.

Well, how do I add login name and password to the 360works ScriptMaster SMTP examples?

For any answer thanks a lot in advance!

Sincerely,

Therese

Link to comment
Share on other sites

How about this function in SMTPit?

SMTPit_SetAuthentication( Type {; Username {; Password {; UseSSL }}} )

/*

Type = The Type of Authentication. [specify "None", "Default", "Plain", "Login", "CRAM-MD5", or "Auto".]

Username = Your account Username.

Password = Your account Password.

UseSSL = Set to True if your mail server requires SSL/TLS/STARTTLS.

*/

Link to comment
Share on other sites

Your're right, it should be something like this -- login with username and password.

However I'd like to do it without SMTPit (which of course is a taylored solution for that task) by simply using the correct lines of code within JAVA resp. GroovyScript.

As far as I know there are JAVA clients capable of sending mails with authentification, so the question simply is -- how? Which maybe three lines of code are used in Java to do SMTP authentfication?

Sincerely,

Therese

Link to comment
Share on other sites

Dear Jesse,

thanks a lot. I've also got the hint I could have googled myself a bit ;-)

The most important lines in the JAVA example you mentioned seem to be to me:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import javax.mail.Authenticator;

import javax.mail.PasswordAuthentication;

...

private static final String SMTP_AUTH_USER = "myusername";

private static final String SMTP_AUTH_PWD = "mypwd";

...

props.put("mail.smtp.auth", "true");

Authenticator auth = new SMTPAuthenticator();

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

props.put(...) translates to

System.setProperty (...)

The JAVA authentification module obviously relies on the static variables SMTP_AUTH_USER and SMTP_AUTH_PWD.

In a first try I simply copied the lines with

private static final String ...

into the groovy script -- and got a nice two pages error notification basically stating that groovy script doesn't understand SMTPAuthenticator() (probably part of the javax.mail.Authenticator module). And without this line of course there is a two pages error notification starting with javax.mail.AuthenticationFailedException.

I'm going to see whether I can find a debug for the import of the needed classes.

Sincerely,

Therese

Link to comment
Share on other sites

  • 6 years later...

I tried to use Sending Mail with Auntethication using scriptmaster, but through a MANDRIL server smtp............ Cannot do it because Mandril use another port 587 ( i think ), different from 25 port.

 

Any idea to fix that ???? thanks a lot.

Link to comment
Share on other sites

you should be able to set the port by doing props.setProperty("mail.smtp.port", 587), before the initialization of the MimeMessage.

 

On a sidenote, it's generally considered bad form to dig up years-old topics like this. It's good to do research (in finding these topics), but if you have a different question, it's better to start your own topic.

Link to comment
Share on other sites

four steps with newer javax code implementation

 

at start

props = new Properties()
props.setProperty('mail.smtp.auth', 'true')
props.setProperty('mail.smtp.timeout', 1000)

then make the msg

PORT is an integer with your port number

 

using javamail 1.5

transport = Session.getDefaultInstance(props).getTransport('smtp')
transport.connect(HOST, PORT, username, password)
transport.sendMessage(msg, msg.getAllRecipients())
transport.close()

good place to start will be the examples on the api page

https://java.net/projects/javamail/pages/Home

Link to comment
Share on other sites

This topic is 3348 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.