Sending Emails from Amber Application

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending Emails from Amber Application

horrido
What's the best way to do this? Does Smalltalk/Amber have a facility for sending (SSL) email via an email relay such as Gmail? This is what I do in Python and Go apps.

The ability to send emails from within my Amber app is critical. If Smalltalk/Amber doesn't have a way, perhaps I can use some third-party JS library? (I'm not aware of any, but then I don't use JS much.)

Thanks.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Sending Emails from Amber Application

Herby Vojčík


Richard Eng wrote:
> What's the best way to do this? Does Smalltalk/Amber have a facility
> for sending (SSL) email *via an email relay such as Gmail*? This is
> what I do in Python and Go apps.
>
> The ability to send emails from within my Amber app is critical. If
> Smalltalk/Amber doesn't have a way, perhaps I can use some third-party
> JS library? (I'm not aware of any, but then I don't use JS much.)

Yes, that's the way for most things. Take a JS library if there is a decent one and use it. Use for example microjs.com to find one.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Sending Emails from Amber Application

philippeback
In reply to this post by horrido


On Mon, Dec 22, 2014 at 2:50 PM, Richard Eng <[hidden email]> wrote:
>
> What's the best way to do this? Does Smalltalk/Amber have a facility for sending (SSL) email via an email relay such as Gmail? This is what I do in Python and Go apps.
>
> The ability to send emails from within my Amber app is critical. If Smalltalk/Amber doesn't have a way, perhaps I can use some third-party JS library? (I'm not aware of any, but then I don't use JS much.)


I guess that you do not run Python in the browser, so as long as you are on a server w/ NodeJs (running Amber on Node for example), you can use things like
http://www.nodemailer.com/

It may be interesting to have a sample fully in Amber indeed. You may want to read:

https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back
https://github.com/amber-smalltalk/amber/wiki/Getting-started-with-Amber-and-socket.io
https://github.com/amber-smalltalk/amber/wiki/Literal-notation

for examples on how to map the JS code to Amber code.

Here is a snippet from nodemailer (checkmarks are artifacts when posting, check the nodemailer site...)

var nodemailer = require('nodemailer');

// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: '[hidden email]',
        pass: 'userpass'
    }
});

// NB! No need to recreate the transporter object. You can use
// the same transporter object for all e-mails

// setup e-mail data with unicode symbols
var mailOptions = {
    from: 'Fred Foo ✔ <[hidden email]>', // sender address
    to: '[hidden email], [hidden email]', // list of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world ✔', // plaintext body
    html: '<b>Hello world ✔</b>' // html body
};

// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
    if(error){
        console.log(error);
    }else{
        console.log('Message sent: ' + info.response);
    }
});


HTH

Phil
>
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.




--
---
Philippe Back
Visible Performance Improvements
Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027
[hidden email] | Web: http://philippeback.eu
Blog: http://philippeback.be | Twitter: @philippeback
Youtube: http://www.youtube.com/user/philippeback/videos

High Octane SPRL
rue cour Boisacq 101 | 1301 Bierges | Belgium

Pharo Consortium Member - http://consortium.pharo.org/
Featured on the Software Process and Measurement Cast - http://spamcast.libsyn.com
Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller
 

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.