zh Kooboo Logo Documents

Mail

 

Kooboo uses the SMTP protocol to send emails. Kooboo supports the IMAP protocol for receiving emails.
 
 
SMTP
 
In the online version of Kooboo, there is a built-in SMTP server for sending emails. Certain membership levels are required, and the sending domain must be the user's domain and use Kooboo's DNS server. There are no restrictions on sending emails via an external SMTP server.
 
var msg = {
    to: "sample@sample.com",
    from: "me@me.com",
    subject: "this is a test email",
    body: "some html body"
};
k.mail.smtp.send(msg);
 
The code for using an SMTP server is as follows:
 
var msg = k.mail.createMessage();
msg.from ="1234567892@qq.com";
msg.to = "guoqi@sample.cn";
msg.subject = "Test Subject";
msg.htmlBody = " Html body content ";
msg.addAttachment("https://www.kooboo.cn/img/logo-white.png");

var server = k.mail.createSmtpServer();
server.host = "smtp.qq.com";
server.port = 465 ;
server.ssl = true;
server.username = "1234567892@qq.com";
server.password = "your_password_here";

k.mail.smtp.send(server, msg);
 
 
IMAP
 
IMAP clients methods are a simplified version and do not cover all the IMAP  client/server commands. Kooboo has a built-in complete IMAP server that supports all the IMAP server syntax.
 
Here is a simple method to receive emails from an IMAP server using Kooboo:
 
var setting = {emailAddress: "123456789@qq.com", host: "imap.qq.com", forceSSL: true, port: 993, password:"your_password_here"};
 
var range = k.mail.imap.getRange(setting)
  
var list = k.mail.imap.collect(setting, 1, 10); 
var msg = k.mail.utility.parseDetail(list[0].rawBody); 
k.response.write(msg.html);