Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

Send E-mail using Javamail problems & questions

xofanfxofanf Members
edited April 2014 in Sahi - Open Source
OS name: Windows
Browser name and version: IE 9
Sahi build number: 2013-04-29

Hello,

I am trying to send e-mail using Javamail and having a hard time. I've searched Sahi Forum and read every discussion in the result, but I still have a few questions to ask.

I think I configured external class path correctly, Mailer constructor is being called, but I cannot send an e-mail. It stucks inside send() function in Mailer class.

My Question is:
1. I saw some example code for sending e-mails in Sahi, and I see the 5th parameter called $isSSL. (ex - http://sahi.co.in/docs/troubleshooting/send-email-issues.html)
However, when I add the fifth parameter, I get:
Java constructor for "net.sf.sahi.ant.Mailer" with arguments "string,number,string,string,boolean" not found. (RhinoScriptRunner.run#292)

Inside Mailer.java I don't see the fifth param, and any configuration to Javamail for SSL. Am I running the old version of Sahi or something? What should I do if SSL is required (ex, GMail with port 465)

2. As a solution to Q1, I modified Mailer.java file in notepad:
sahi\src\net\sf\sahi\ant\Mailer.java

However, the changes I made were not being called, or applied. How do I customize the Mailer.java file? I wonder if Java needs to be compiled after the changes in order to use the updated class? Could you explain the steps? Or is it not possible/recommended to customize Mailer.java file?

I don't know what i'm doing wrong, any help would be appreciated.

Answers

  • xofanfxofanf Members
    I figured this out after spending hours... I struggled because I did not know about .jar file.
    As a solution, I had to do these:
    1. Update Mailer.java with text editor.
    sahi\src\net\sf\sahi\ant\Mailer.java
    
    This site was very helpful: http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/

    *For Password Authentication, I also had to add this line to the Mailer.java file.
    import javax.mail.PasswordAuthentication;
    

    2. Navigate to sahi\src\net\sf\sahi\ant\ and compile Mailer.java running javac command. This will generate .class file(s). You may need to download java or set environment variable in order to run javac command.
    This is the command I used:
    javac -cp .;C:\Users\me\sahi\userdata\extlib\mail\mail.jar;C:\Users\me\sahi\userdata\extlib\mail\activation.jar Mailer.java
    

    3. Extract sahi\lib\ant-sahi.jar and navigate to Mailer.class file

    4. Copy & Paste the class file(s) you generated in step #2.

    5. Compress the 'net' folder you extracted to a new ant-sahi.jar file. Here is the command I used:
    jar -cf net/ ant-sahi.jar
    

    6. Copy & Paste the jar in step #5 to the sahi/lib folder.

    Hope this helps.
Sign In or Register to comment.