Sendin mail

496 views
Skip to first unread message

Luigi

unread,
May 31, 2010, 4:56:07 PM5/31/10
to sahi
Hi to all,
is it possible to send email via SAHI?

I'm running SAHI on windows machine... otherwise I would have used a
shell script with _execute($script_path);

Any suggestion?

Regards,
Luigi

Narayan Raman

unread,
Jun 1, 2010, 1:30:05 AM6/1/10
to sa...@googlegroups.com
Hi Luigi,

There is a small class in Sahi which can be used to send emails. You could use it like this:

var $host = "smtp.myserver.com";
var $port = 25;
var $username = "mye...@example.com";
var $password = "mypassword";
var $mailer = new net.sf.sahi.ant.Mailer($host, $port, $username, $password);
$mailer.send("fr...@example.com", "t...@example.com", "my subject", "my email body");

Note that it works only for smtp which does not need ssl or tls. We can add support for ssl/tls if needed. If you do not need a username password, use 
var $mailer = new net.sf.sahi.ant.Mailer($host, $port);

Regards,
Narayan



--
You received this message because you are subscribed to the Google Groups "sahi" group.
To post to this group, send email to sa...@googlegroups.com.
To unsubscribe from this group, send email to sahi+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sahi?hl=en.




--
Tyto Software Pvt. Ltd
http://www.tytosoftware.com
http://sahi.co.in
+91 98809 65555

http://blog.sahi.co.in
http://twitter.com/_sahi

Narayan Raman

unread,
Jun 1, 2010, 1:38:00 AM6/1/10
to sa...@googlegroups.com
I forgot to mention that you would need mail.jar and activation.jar from java mail for this. (http://java.sun.com/products/javamail/downloads/index.html)
You will also need to add these jars to Sahi's classpath in start_sahi.bat

@ECHO OFF
SET SAHI_HOME=..\..
SET SAHI_USERDATA_DIR=..
SET SAHI_EXT_CLASS_PATH=%SAHI_HOME%\extlib\mail\mail.jar;%SAHI_HOME%\extlib\mail\activation.jar
CALL %SAHI_HOME%\bin\sahi.bat

Luigi

unread,
Jun 1, 2010, 12:24:20 PM6/1/10
to sahi
Perfetto!

Thanks a lot!

On 1 Giu, 07:38, Narayan Raman <nara...@sahi.co.in> wrote:
> I forgot to mention that you would need mail.jar and activation.jar from
> java mail for this. (http://java.sun.com/products/javamail/downloads/index.html)
> You will also need to add these jars to Sahi's classpath in start_sahi.bat
>
> @ECHO OFF
> SET SAHI_HOME=..\..
> SET SAHI_USERDATA_DIR=..
> SET
> SAHI_EXT_CLASS_PATH=%SAHI_HOME%\extlib\mail\mail.jar;%SAHI_HOME%\extlib\mail\activation.jar
> CALL %SAHI_HOME%\bin\sahi.bat
>
>
>
> On Tue, Jun 1, 2010 at 11:00 AM, Narayan Raman <nara...@sahi.co.in> wrote:
> > Hi Luigi,
>
> > There is a small class in Sahi which can be used to send emails. You could
> > use it like this:
>
> > var $host = "smtp.myserver.com";
> > var $port = 25;
> > var $username = "myem...@example.com";
> > var $password = "mypassword";
> > var $mailer = new net.sf.sahi.ant.Mailer($host, $port, $username,
> > $password);
> > $mailer.send("f...@example.com", "t...@example.com", "my subject", "my email
> > body");
>
> > Note that it works only for smtp which does not need ssl or tls. We can add
> > support for ssl/tls if needed. If you do not need a username password, use
> > var $mailer = new net.sf.sahi.ant.Mailer($host, $port);
>
> > Regards,
> > Narayan
>
> > On Tue, Jun 1, 2010 at 2:26 AM, Luigi <l.fug...@gmail.com> wrote:
>
> >> Hi to all,
> >> is it possible to send email via SAHI?
>
> >> I'm running SAHI on windows machine... otherwise I would have used a
> >> shell script with _execute($script_path);
>
> >> Any suggestion?
>
> >> Regards,
> >> Luigi
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "sahi" group.
> >> To post to this group, send email to sa...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> sahi+uns...@googlegroups.com <sahi%2Bunsu...@googlegroups.com>.
> >> For more options, visit this group at
> >>http://groups.google.com/group/sahi?hl=en.
>
> > --
> > Tyto Software Pvt. Ltd
> >http://www.tytosoftware.com
> >http://sahi.co.in
> > +91 98809 65555
>
> >http://blog.sahi.co.in
> >http://twitter.com/_sahi
>
> --
> Tyto Software Pvt. Ltdhttp://www.tytosoftware.comhttp://sahi.co.in+91 98809 65555begin_of_the_skype_highlighting              +91 98809 65555      end_of_the_skype_highlighting
>
> http://blog.sahi.co.inhttp://twitter.com/_sahi

lonely_girl01

unread,
Jul 11, 2012, 11:24:47 PM7/11/12
to sa...@googlegroups.com
Hi Narayan,

I've checked the downloads from the link you provided (Java Mail API). But, i can't seem to find where to download activation.jar.


Thanks and regards.
To unsubscribe from this group, send email to sahi+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sahi?hl=en.

Narayan Raman

unread,
Jul 12, 2012, 6:50:50 AM7/12/12
to sa...@googlegroups.com
Hi,

activation.jar is not required if you are using Java 6 or later. 

To quote from Oracle website:

" Note: Unless you're using Java SE 6, you will also need the JavaBeans Activation Framework (JAF) extension that provides the javax.activation package. We suggest you use version 1.1.1 of JAF, the latest release. JAF is included with Java SE 6 and 7. "


Hope that helps.

Regards,
Narayan


To view this discussion on the web visit https://groups.google.com/d/msg/sahi/-/KHQ8hD8s-GcJ.

To post to this group, send email to sa...@googlegroups.com.
To unsubscribe from this group, send email to sahi+uns...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sahi?hl=en.



--
Narayan Raman  | +91 98809 65555 
Tyto Software Pvt. Ltd. http://sahi.co.in (@_sahi)


Reply all
Reply to author
Forward
0 new messages