Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you write an example to forward message to email using smtp? #9

Closed
ccaapton opened this issue Jul 4, 2016 · 1 comment
Closed
Labels

Comments

@ccaapton
Copy link

ccaapton commented Jul 4, 2016

Hi, zixia. Your wechat library looks fantastic!

I want to write a simple bot to forward all received messages to email using smtp, but I'm not very familiar with the js/npm language/eco system. Could you write a simple example to do this? Thanks a lot!

@huan
Copy link
Member

huan commented Jul 4, 2016

Hi ccaapton,

Thanks for using wechaty.

I'd like to help you, but I believe you could do that with a library named emailjs, because it's very clean and easy to use.

emailjs: https://github.com/eleith/emailjs

a example code from it's document:

var email   = require("./path/to/emailjs/email");
var server  = email.server.connect({
   user:    "username", 
   password:"password", 
   host:    "smtp.your-email.com", 
   ssl:     true
});

// send the message and get a callback with an error or details of the message that was sent
server.send({
   text:    "i hope this works", 
   from:    "you <[email protected]>", 
   to:      "someone <[email protected]>, another <[email protected]>",
   cc:      "else <[email protected]>",
   subject: "testing emailjs"
}, function(err, message) { console.log(err || message); });

If you have any issue with emailjs, feel free to post here and let me know the problem.

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants