Telepski Posted May 28, 2008 Posted May 28, 2008 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
bcooney Posted May 29, 2008 Posted May 29, 2008 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. */
Telepski Posted May 30, 2008 Author Posted May 30, 2008 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
Jesse Barnum Posted May 31, 2008 Posted May 31, 2008 Sam knows the Java mail code better than I do, but I did find this code snippet from a google search: http://www.rgagnon.com/javadetails/java-0538.html
Telepski Posted May 31, 2008 Author Posted May 31, 2008 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
jsubiros Posted March 12, 2015 Posted March 12, 2015 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.
evanseeds Posted March 12, 2015 Posted March 12, 2015 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.
john renfrew Posted March 12, 2015 Posted March 12, 2015 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
Recommended Posts
This topic is 3555 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 accountSign in
Already have an account? Sign in here.
Sign In Now