Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
aminegac
Creator

SMTPSendFailedException: 530 5.7.1 Client was not authenticated MS Exchange Server

hello, i have this blocking problem where i cannot send email using port 587 where it uses authentification as config and i put the correct values it always says SMTPSendFailedException: 530 5.7.1 Client was not authenticated.

I want to use port 587 so i can send emails to external addresses from my company.(i use port 25 with no authentification to send mails to internal addresses)

so the problem here is that it works totally fine with the same configuration from my java apps and web services using port 587 and authenticating using a specific account but in Talend it does not work and shows that error . so the problem is from Talend for sure !

note that if i check use SSL there is another error also same happend when i check STARTTLS ! (in my java apps where its working i don't use those 2 protocols )

note that i cannot modify "allow send anonymous mails" from exchange config cause it is against our security terms !

Talend OS 4 yrs / Java 17 Web Dev
Labels (4)
12 Replies
aminegac
Creator
Author

I also checked all existing discussions here in talend community and none of them solved my problem and almost most of them have not been resolved !!

i don't consider my question as duplicate because this specific case has never been solved (where the exact same config works in java but not in talend )

🙂

Talend OS 4 yrs / Java 17 Web Dev
Anonymous
Not applicable

Would you mind showing us your component configuration and maybe even the Java where you say this work? Obviously hide any personal values. I'd like to try and emulate this if I can. It's really hard to tackle problems like this without actually seeing them.

aminegac
Creator
Author

thank you for replying ,

here are the 2 configs from my java working mail and from talend non working mail ;

in talent the job has only 1 component which is tsendmail ; just to test the mail only and limit errors to the mail component.

everything in both configs is the same

same password ; user , adressFROM ,smtp service ; port

0695b00000LwPLJAA3.png0695b00000LwPJEAA3.pngthank you

Talend OS 4 yrs / Java 17 Web Dev
Anonymous
Not applicable

OK, first of all, if this is a blocker you can use your Java in a Talend Routine. You could then call it in a tJavaFlex to send the mails. In fact, it might be a nice test to do that to see whether this is something connected to the Studio network settings (a small possibility, but worth the test and it gets you going again).

 

I'll try and reproduce this from what you have sent.

Anonymous
Not applicable

@amine kacem​ , see below my configurations, it works with outlook SMTP host "smtp.outlook.office365.com" and port 587, the STARTTLS box is checked.

0695b00000LwXWUAA3.pngIf the STARTTLS box is unchecked, it will throws this error.

Starting job testConn at 12:12 09/12/2021.

[statistics] connecting to socket on port 3416

[statistics] connected

Exception in component tSendMail_1 (testConn)

com.sun.mail.smtp.SMTPSendFailedException: 451 5.7.3 STARTTLS is required to send mail [SJ0PR05CA0114.namprd05.prod.outlook.com]

 

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2358)

at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1823)

at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)

at javax.mail.Transport.send0(Transport.java:255)

at javax.mail.Transport.send(Transport.java:124)

at back_up_project.testconn_0_1.testConn.tSendMail_1Process(testConn.java:768)

at back_up_project.testconn_0_1.testConn.runJobInTOS(testConn.java:1482)

at back_up_project.testconn_0_1.testConn.main(testConn.java:1082)

[FATAL] 12:12:34 back_up_project.testconn_0_1.testConn- tSendMail_1 451 5.7.3 STARTTLS is required to send mail [SJ0PR05CA0114.namprd05.prod.outlook.com]

 

If you are a Java developer, you can look into the generated Java code to see whether the component use the same API as your Java app.

0695b00000LwXb0AAF.png 

In addition, as rhall suggested, write your code in a routine and call it in the job, to see whether you have issues to send emails using your code from talend job.

Regards

Shong

 

aminegac
Creator
Author

@Richard Hall​ clever idea , never thought about using that although i already used them before ; i will try and check if it worked it will make a lot of other similar tasks better ; thx 🙂

just one thing : how can i import a jar so that my routine can import successfully the jars methods ? all i need is to make imports javax.mail' so i need to put the related jar some where else so i can save the code in routine .i found a way to add it to libraries through preferences interface but still it does show an error and it can't find those imports .

0695b00000LwZVnAAN.png 0695b00000LwZRWAA3.png@Shicong Hong​ thank you for the suggestion , but it does not worked for me , i think it is because we don't have access to that domain from our company mails ; we already have our OWN EXCHANGE server , that's why i am using our IP/domain of smtp to authenticate , so i am sure the ip of smtp server is correct ; also when i try my param and try to enable starttls it shows this exception :

javax.mail.MessagingException: Can't send command to SMTP host;

 nested exception is:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

when i try my params and no starttls or ssl it just keep saying 530 5.7.1 Client was not authenticated

could it be because the account username is "XXX\nXXXX" ??? maybe because of the '\' and the 'n' so even if i add another '\' it will still be specific char '\\n' its like i tell him make a line break ! should i add a tripe '\' so it becomes '\\\n' first for the '\' and third for the 'n' !

but in java all i do is write 'XXXX\\nXXX' and it is working , which means i only need to add 1 additional '\' .

Talend OS 4 yrs / Java 17 Web Dev
Anonymous
Not applicable

About import required jar, right click on your routine and click 'edit routine libraries' option to add external jars.

About account username, for testing, print the account name on a tJava to see if the value is what your expected string output.

String accountName= "abc\\nabc";

System.out.println(accountName);

 

and is it possible to use another account name without any special characters for testing? just like "shong@talend.com", because the error indicates username/password is not correct.

 

Regards

Shong

 

 

aminegac
Creator
Author

Thx for the fast reply ; i really like the Costumer service these days although it's for free software solutions . 🙂

for first try i just focused on making the routine code

and it worked after many attempts ;

thx a lot

but i will still check tomorrow the other method .

so now we are sure it work from java routine ! so maybe in TSendMail there is a bug ; maybe .

 

so for people who have my prob here is what you have to do is to add the jar as a module in module interface that you can show from preference menu "show interfaces"

and than add your mail jar with the icon of import jar like in the photo . and your imports in the routine will be validated.

more than that after making the code you can use it in Tjava component and there you need to add TLibraryLoad and import your mail jar too ; so that you overcome the exception of java/mail class not found or something .

0695b00000Lwby8AAB.png 

0695b00000LwbyIAAR.png😉

Talend OS 4 yrs / Java 17 Web Dev
Anonymous
Not applicable

You could also add your code to a routine and link the Jar to the routine. To link the Jar to routine, follow this help document.....

https://help.talend.com/r/en-US/7.2/studio-user-guide-open-studio-for-data-integration/editing-user-routine-libraries

 

Doing it this way means that you do not have to have the code written inside each job you want to use it with and you do not have to add the library to each job....because it is linked to the routine.