18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Send an email from Sahi script
Hi,
I want to send an email from my SAHI script.
I have tried the following code in the script:
var $host = "smtp.gmail.com";
var $port = 25;
var $username = "test@gmail.com";
var $password = "test";
var $mailer = new net.sf.sahi.ant.Mailer($host, $port, $username,$password);
$mailer.send("test@test.com", "test@test.com", "my subject", "Test Mail from SAHI");
However i get the following error:
ERROR
TypeError: Cannot call property Mailer in object [JavaPackage net.sf.sahi.ant]. It is not a function, it is "object"
I have searched every topic in this form and cannot find a solution.
also i have tried a try and catch to see if there is any other error, the exception only says object object.
i have tried console.log but this does not work in SAHI.
Please advise
Thanking you
Gavlin
I want to send an email from my SAHI script.
I have tried the following code in the script:
var $host = "smtp.gmail.com";
var $port = 25;
var $username = "test@gmail.com";
var $password = "test";
var $mailer = new net.sf.sahi.ant.Mailer($host, $port, $username,$password);
$mailer.send("test@test.com", "test@test.com", "my subject", "Test Mail from SAHI");
However i get the following error:
ERROR
TypeError: Cannot call property Mailer in object [JavaPackage net.sf.sahi.ant]. It is not a function, it is "object"
I have searched every topic in this form and cannot find a solution.
also i have tried a try and catch to see if there is any other error, the exception only says object object.
i have tried console.log but this does not work in SAHI.
Please advise
Thanking you
Gavlin
Comments
Kindly have a look at:
http://sahi.co.in/forums/viewtopic.php?id=2768
Let me know if you face any problem.
Regards
sumitra
I have tried this solution and it does not seem to work, it still says:
Cannot call property Mailer in object [JavaPackage net.sf.sahi.ant]. It is not a function, it is "object"
Please advise
You will have to add the ant-sahi.jar file into the classpath. Follow the below link to add the jar file:
http://sahi.co.in/w/adding-jars-to-sahis-classpath
Regards
Sumitra
Im facing the same issue, i have already change my classpath, and added mail.jar and ant-sahi.jar, but still the same issue.
Would you mind please help me find out what's wrong.
thanks for your help.
Maha
Same issue is encountered with me. I have followed exact steps but recieving the error "[JavaPackage net.sf.sahi.ant.Mailer] is not a function, it is object." .
Please suggest any resolution for this.
Thanks,Nalini
Also have the same error but fixed already.
Here's what i put in:
Regards.
i added jars to class path as you said but still i am getting the same error.
ERROR
TypeError: [JavaPackage net.sf.sahi.ant.Mailer] is not a function, it is object. at Jul 24, 2012 9:14:58 PM
ERROR
TypeError: [JavaPackage net.sf.sahi.ant.Mailer] is not a function, it is object. (RhinoScriptRunner.run#52) at Jul 24, 2012 9:14:58 PM
i am getting this error.
after addding jars to sahi classpaths
Java constructor for "net.sf.sahi.ant.Mailer" with arguments "string,number,string,string,boolean" not found. at Jul 24, 2012 9:37:30 PM
ERROR
Java constructor for "net.sf.sahi.ant.Mailer" with arguments "string,number,string,string,boolean" not found. (RhinoScriptRunner.run#52) at Jul 24, 2012 9:37:30 PM
- download 2 jars: activation.jar and mail.jar: refer http://sahi.co.in/w/adding-jars-to-sahis-classpath
- Add 3 jars: activation.jar, mail.jar and ant.sahi.jar to the class path.
- run this code
var $host = "smtp.gmail.com";
var $port = 25;
var $username = "test@gmail.com";
var $password = "test";
var $mailer = new net.sf.sahi.ant.Mailer($host, $port, $username,$password);
$mailer.send("test@test.com", "test@test.com", "my subject", "Test Mail from SAHI");
Even i am facing the same issue as : - "Java constructor for "net.sf.sahi.ant.Mailer" with arguments "string,number,string,string,boolean" not found. "
the function is
function sendEmail($emailsubject,$emailbody)
{
var $host="smtp.gmail.com";
var $port=465;
var $username="from@gmail.com";
var $password="password";
var $isSSL=true;
var $mailer=new net.sf.sahi.ant.Mailer($host,$port,$username,$password,$isSSL);
var $from="test@gmail.com"
var $to="testing1@gmail.com";
$mailer.send($from,$to,$emailsubject,$emailbody);
}
I have added all the jars to sahi class path as well :
SET SAHI_EXT_CLASS_PATH=D:\SAHIV3-5\extlib\mail\mail.jar;D:\SAHIV3-5\extlib\mail\activation.jar;D:\SAHIV3-5\lib\ant-sahi.jar;
Sahi : Build: 2011-07-19
OS : windows 7
java :1.5.0_14
Please advise
Regards,
Bhavitha
ERROR
TypeError: [JavaPackage net.sf.sahi.ant.Mailer] is not a function, it is object. (RhinoScriptRunner.run#101) .
I have added all the required 3 jars at the desired location but still getting this error.
Kindly advise how to resolve that.
please check on the port.
-Ashokan P
Please check the path of the included "ant-sahi.jar" file.
That is where the problem should be.
Regards,
Pratyush