Can you write an example to forward message to email using smtp?
Closed this issue · 1 comments
ccaapton commented
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 commented
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 <username@your-email.com>",
to: "someone <someone@your-email.com>, another <another@your-email.com>",
cc: "else <else@your-email.com>",
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!