emailserverwakanda

Cannot send email with Wakanda Server 1.1.3


When I attempt to send an email via Wakanda Server, using the following code, an error occurs:

var mail = require('waf-mail/mail');
var message = new mail.Mail();
message.subject = "Here the subject of the email";
message.from = "me@mydomain.com";
message.to = 'user@somedomain.com';
message.setBody("This is a test message");

mail.send({
    address: 'mail.mydomain.com',
    port: 587,
    isSSL: true,
    username: 'MY-USERNAME',
    password: 'MY-PASSWORD',
    domain: 'mydomain.com'
}, message);

When running in debug mode, during mail.send the error occurs at the following line:

socket = tls.connect(port, address, connectCallback);

When debugging, I cannot step into this function call and the error occurs when attempting to do so.

The docs say that mail.send should return a status object, but that doesn't happen here. Adding a try/catch to the mail.send call produces this Error object in the catch:

Error = {
    error: [{
        componentSignature: "xbox"
        errCode: 5
        message: ""}],
    messages: [""]
}

Wakanda Server 1.1.3

MacOS 10.11.6

I am not using gmail to send the email.


Solution

  • Make sure you have the correct address and port in the mail.send properties. you have to search the correct smtp settings for the mail you are using. for gmail i succed sending emails using the following :

    var mail = require('waf-mail/mail'); 
    var message = new mail.Mail();
    message.subject = "Test";
    message.from = "me@gmail.com";
    message.to = ['me@gmail.com' , 'user@wakanda.io'];
    message.setBody("This is a test message");
    mail.send({
        address: 'smtp.gmail.com', 
        port: 465,
        isSSL: true,
        username: 'username', 
        password: 'password', 
        domain: 'gmail.com'
    }, message);