Error sending mail

Hi team,

I have tried to send mail using this code in bot task.It’s showing an error.

<?xml version="1.0" encoding="UTF-8"?>
        <config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config">

        <var-def name="applicationHost">https://vr1684.workfusion.com</var-def>

<mail 	from="from@organisation.com"
		smtp-host="smtp.office365.com"
		smtp-port="587"
		to="to@organisation.com"
		username="username@organisation.com"
		password="password of my mail"
		security="ssl"
		type="text"
		subject="mail test">	  

		
</mail>
     <export include-original-data="true"></export>
            
        </config>

I am getting the following error log, I am attaching the error log

06:27:04 [INFO] VarDefProcessorValidated starts processing…
06:27:04 [WARN] You use reserved variable name(s) ‘applicationHost’ in your script . That can cause unpredictable behaviour (including crashes) and will be forbidden in future versions. Please consider renaming the variable.
06:27:04 [INFO] ConstantProcessor starts processing…
06:27:04 [INFO] ConstantProcessor processor executed in 0ms.
06:27:04 [INFO] VarDefProcessorValidated processor executed in 7ms.
06:27:04 [INFO] MailPlugin starts processing…
06:27:05 [ERROR] org.apache.commons.mail.EmailException: Invalid message supplied
org.webharvest.runtime.processors.plugins.MailPluginException: org.apache.commons.mail.EmailException: Invalid message supplied
at org.webharvest.runtime.processors.plugins.MailPlugin.executePlugin(MailPlugin.java:116)
at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.processTaskInputs(SingleThreadWebHarvestProcess.java:77)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.start(SingleThreadWebHarvestProcess.java:46)
at com.workfusion.studio.launch.WebHarvestMainLauncher.launch(WebHarvestMainLauncher.java:108)
at com.workfusion.studio.launch.WebHarvestMainLauncher.main(WebHarvestMainLauncher.java:180)
Caused by: org.apache.commons.mail.EmailException: Invalid message supplied
at org.apache.commons.mail.SimpleEmail.setMsg(SimpleEmail.java:41)
at org.webharvest.runtime.processors.plugins.MailPlugin.executePlugin(MailPlugin.java:114)
… 9 more
06:27:05 [INFO] -------------------------------------------
06:27:05 [INFO] EXECUTION FAILED
06:27:05 [INFO] Invalid message supplied (CBRS_bot_task.xml:14)
06:27:05 [INFO] -------------------------------------------

@ravikumar177 You need to add some email message text.

<mail 	from="from@organisation.com"
		smtp-host="smtp.office365.com"
		smtp-port="587"
		to="to@organisation.com"
		username="username@organisation.com"
		password="password of my mail"
		security="ssl"
		type="text"
		subject="mail test">	  
email message		
</mail>
1 Like

Hi,
I have added some message, still it doesn,t run fine.

The error is “java,net.ConnectException”

It is a different exception. Can you share the full text?

Also, do you execute the same code you shared above?

This is the error that it displays:

02:29:09 [INFO] VarDefProcessorValidated starts processing…
02:29:09 [WARN] You use reserved variable name(s) ‘applicationHost’ in your script . That can cause unpredictable behaviour (including crashes) and will be forbidden in future versions. Please consider renaming the variable.
02:29:09 [INFO] ConstantProcessor starts processing…
02:29:09 [INFO] ConstantProcessor processor executed in 0ms.
02:29:09 [INFO] VarDefProcessorValidated processor executed in 10ms.
02:29:09 [INFO] MailPlugin starts processing…
02:29:09 [INFO] ConstantProcessor starts processing…
02:29:09 [INFO] ConstantProcessor processor executed in 0ms.
02:29:30 [ERROR] org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.office365.com:465
org.webharvest.runtime.processors.plugins.MailPluginException: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.office365.com:465
at org.webharvest.runtime.processors.plugins.MailPlugin.executePlugin(MailPlugin.java:123)
at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.processTaskInputs(SingleThreadWebHarvestProcess.java:77)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.start(SingleThreadWebHarvestProcess.java:46)
at com.workfusion.studio.launch.WebHarvestMainLauncher.launch(WebHarvestMainLauncher.java:108)
at com.workfusion.studio.launch.WebHarvestMainLauncher.main(WebHarvestMainLauncher.java:180)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.office365.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469)
at org.apache.commons.mail.Email.send(Email.java:1496)
at org.webharvest.runtime.processors.plugins.MailPlugin.executePlugin(MailPlugin.java:121)
… 9 more
Caused by: com.sun.mail.util.MailConnectException: Couldn’t connect to host, port: smtp.office365.com, 465; timeout 60000;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2118)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
… 11 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:329)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:217)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2084)
… 18 more
02:29:30 [INFO] -------------------------------------------
02:29:30 [INFO] EXECUTION FAILED
02:29:30 [INFO] Connection timed out: connect (CBRS_bot_task.xml:16)
02:29:30 [INFO] -------------------------------------------

@ravikumar177 try using these SMTP setting https://support.google.com/accounts/answer/6010255?hl=en

Also note that if you send it from your corporate email, some security settings can prevent you from sending emails through bots.

The code which is written is used to send mail through outlook.

Please go through the steps that i had performed:

I have created an xml file,where i had written this mail code to send mail from outlook.
I tried to run it in console but not able to do so because of java.net.connect exception.

Will u Please give an example of sending mail using gmail .
Also please share screenshot for better Understanding
Should I run this as “Run as bot task” or should I have to publish it to control tower.
Thanks in Advance.

Please let me know how to change the settings.

Hi Team,

Please provide a sample demo of sending mail.
This would help us to understand it much better.

Thanks

@ravikumar177 here is an example of working code to send an email from Gmail:

<?xml version="1.0" encoding="UTF-8"?>
<config
	xmlns="http://web-harvest.sourceforge.net/schema/1.0/config"
	scriptlang="groovy">

	<robotics-flow>
		<robot driver="universal" close-on-completion="true"
			start-in-private="false">
			<capability name="SEARCH_ALL_WINDOWS" value="true" />
			<capability name="CLOSE_ALL_WINDOWS" value="false" />
		

<mail 	from="gmail_address@gmail.com"
		smtp-host="smtp.gmail.com"
		smtp-port="465"
		to="recipient_address@email.com"
		username="gmail_address@gmail.com"
		password="google_password"
		security="ssl"
		type="text"
		subject="mail test">	  
This is a test email.
</mail>
		
		</robot>
	</robotics-flow>
	<export include-original-data="true">
    </export>
</config> 

You can execute in from the Code perspective in WorkFusion Studio, or from Control Tower.

1 Like

Hi, I’m trying to use the following code to send an email:

But I’m getting the error below:

@mgutierrez try adjusting this setting in your gmail account

@ashapkina I have used the given code for mail sending by you and also checked “allow less secure apps” settings. Still I am getting the same error…

can you suggest something more?

what are the errors that you get?
Could you share the error

@ravikumar177 Following are the errors I am getting while sending email, I have checked all the required settings.

org.webharvest.runtime.processors.plugins.MailPluginException: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465

Do let me know if anything else required?

Do I need to change anyy settings except that “less secure app”?

Thanks a lot

I think you are trying to execute the code with your office network.
Try it on your own network
It works

@ravikumar177 yes you are correct, When I tried it with my own network, it worked. But Whenever I am trying using office network it throwing these errors. Is there any solution as I can not always use my own network for sending emails?