haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.02k stars 662 forks source link

working starter kit with default options #2351

Closed artalar closed 6 years ago

artalar commented 6 years ago

Hi! I'm just a frontend developer and totally dumb about SMTP. Sometimes I need to implement a simple backend for sending notification emails to my customers. I know the credentials of system account on customer mail server, but I need another one for tests. So I want to create my own SMTP server (only with one account) on Heroku and use it sometimes for tests. I spend 4 hours trying to find some docs for my case, mostly by using Haraka, but I got nothing. For example, in your Screencast using test_queue, but its plugin is [CRIT] [-] [core] Caught exception: "Loading plugin test failed: No plugin with this name found". haraka -l write about 'test' in plugins/queue/, but it returns the same result. I don't understand what is "queue" mean and what exactly plugins I need for my cases. Sory for my dullness, but its hard for me. Have you some "starter kit" with working default options, just for getting emails and send them to destination address?

system info

Haraka Haraka.js — Version: 2.8.17
Node v9.4.0
OS Linux artalar 4.13.0-32-generic #35~16.04.1-Ubuntu SMP Thu Jan 25 10:13:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
openssl OpenSSL 1.0.2g 1 Mar 2016

Expected behavior

Receive email by existing-email@gmail.com

const nodemailer = require('nodemailer');

const mailTransporterConfig = {
  port: 443,
  host: 'mailserver.herokuapp.com', // server with Haraka application
  auth: {
    user: 'username',
    pass: 'password',
  },
}

const  transporter = nodemailer.createTransport(mailTransporterConfig)

const message = {
  from: 'sender@mailserver.herokuapp.com',
  to: 'existing-email@gmail.com',
  subject: 'Message title',
  text: 'Plaintext version of the message',
  html: '<p>HTML version of the message</p>'
};

transporter.sendMail(message)

Is it possible?

artalar commented 6 years ago

Ok, after i add auth/flat_file the nodemailer code is working, but i get errors with Haraka

[INFO] [-] [core] [outbound] Loading outbound queue from /media/artalar/3A865F52865F0DAF/code/mail-server/queue
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143] [core] connect ip=127.0.0.1 port=56754 local_ip=:: local_port=2525
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143] [helo.checks] multi: true, skip:proto_mismatch(private), host_mismatch(private)
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143] [auth/flat_file] ticket: <98551. 161c42c6688@null>
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143] [core]  hook=unrecognized_command plugin=auth/flat_file function=hook_unrecognized_command params=AUTH retval=OK msg=""
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143] [core]  hook=unrecognized_command plugin=auth/flat_file function=hook_unrecognized_command params="dXNlciA0YTA3NDIwNmM0NGYzNjdhMTIzYTg5NzI3ZDIzYTI1Nw=="retval=OK msg=""
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] sender <user@domain.com> code=CONT msg=""
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] recipient <xhakaqeqb@emltmp.com> code=OK msg="" sender=user@domain.com
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] message mid=<9278a47c-df30-2d0c-6c94-0d556a332e98@domain.com> size=576 rcpts=1/0/0 delay=0.011 code=CONT msg=""
[INFO] [-] [core] [smtp_client_pool] [2555:localhost:300] dispense() clients=1 available=0
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [queue/smtp_forward] forwarding to localhost:2555
[WARN] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [queue/smtp_forward] C58594A0-A87A-4054-AF7D-52B803B0B7AE: [localhost:2555] SMTP connection errored Error: connect ECONNREFUSED 127.0.0.1:2555
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] queue code=CONT msg=" (7BA6524C-7AE2-490C-A74F-07DBE9359143.1)"
[INFO] [-] [core] [outbound] Sending email as a transaction
[INFO] [-] [core] [outbound] Processing domain: emltmp.com
[ERROR] [-] [core] backend failure: localhost:2555 - C58594A0-A87A-4054-AF7D-52B803B0B7AE: [localhost:2555] SMTP connection errored Error: connect ECONNREFUSED 127.0.0.1:2555
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] queue code=OK msg="Message Queued (7BA6524C-7AE2-490C-A74F-07DBE9359143.1)"
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] client [127.0.0.1] half closed connection
[NOTICE] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1] [core] disconnect ip=127.0.0.1 rdns=Unknown helo=[127.0.0.1] relay=Y early=N esmtp=Y tls=N pipe=N errors=0 txns=1 rcpts=1/0/0 msgs=1/0/0 bytes=576 lr="" time=0.192
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1.1] [outbound] Looking up A records for: mx.emltmp.com
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1.1] [outbound] Attempting to deliver to: 77.244.213.157:25 (0) (0)
[INFO] [-] [core] [outbound] [outbound::25:77.244.213.157:undefined:50] dispense() clients=1 available=0
[ERROR] [-] [core] [outbound] Failed to get pool entry: Outbound connection timed out to 77.244.213.157:25
[INFO] [7BA6524C-7AE2-490C-A74F-07DBE9359143.1.1] [outbound] Temp failing 1519414699808_1519414699808_0_6354_BuCA5k_1_artalar-8470p for 64 seconds: Tried all MXs
[INFO] [-] [core] [outbound] [outbound::25:77.244.213.157:undefined:50] dispense() clients=0 available=0
^C[NOTICE] [-] [core] SIGINT received
[INFO] [-] [core] Shutting down.
smfreegard commented 6 years ago

Heroku won't allow SMTP servers to function on their network, so this is a dead-end. You'll need to use an ESP like Mailgun, or any other SMTP relay service running elsewhere.

The only way you could do this would be to run Haraka on a host that allows SMTP traffic on port 25.

baudehlo commented 6 years ago

Yeah I thought about making a cloudformation template for it, but AWS won't allow port25 either.

On Fri, Feb 23, 2018 at 3:48 PM, Steve Freegard notifications@github.com wrote:

Heroku won't allow SMTP servers to function on their network, so this is a dead-end. You'll need to use an ESP like Mailgun, or any other SMTP relay service running elsewhere.

The only way you could do this would be to run Haraka on a host that allows SMTP traffic on port 25.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/haraka/Haraka/issues/2351#issuecomment-368134250, or mute the thread https://github.com/notifications/unsubscribe-auth/AAobY9Y0qYreNBMjHsotXojET4CqYpk8ks5tXyQtgaJpZM4SRT5F .

artalar commented 6 years ago

Ok, it works with mailgun