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't enable plugin under Erlang 22 #38

Closed
zabralex85 opened this issue May 29, 2019 · 36 comments
Closed

Can't enable plugin under Erlang 22 #38

zabralex85 opened this issue May 29, 2019 · 36 comments

Comments

@zabralex85
Copy link

zabralex85 commented May 29, 2019

Wan't only to recieve messages from google mail.
example.com - my domain, google suite have bindinx with MX to it via goddady

try: rabbitmq-plugins enable rabbitmq_email
output:

Enabling plugins on node rabbit@main: rabbitmq_email The following plugins have been configured: rabbitmq_email rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch Applying plugin configuration to rabbit@main... (rabbitmqctl) lib/rabbitmqctl.ex:45: RabbitMQCtl.main/1 (elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2

log:

`
2019-05-28 19:08:58.313 [info] <0.8.0> Server startup complete; 3 plugins started.

  • rabbitmq_management
  • rabbitmq_web_dispatch
  • rabbitmq_management_agent
    2019-05-28 19:09:25.547 [warning] <0.633.0> iconv not detected: content transcoding is DISABLED
    2019-05-28 19:09:25.549 [info] <0.634.0> gen_smtp_server starting at rabbit@main
    2019-05-28 19:09:25.549 [error] <0.634.0> CRASH REPORT Process <0.634.0> with 0 neighbours crashed with reason: call to undefined function socket:listen(tcp, 2525, [binary,{ip,{0,0,0,0}},inet])

2019-05-28 19:09:25.550 [error] <0.633.0> Supervisor {<0.633.0>,rabbitmq_email_app} had child email_handler started with gen_smtp_server:start_link(rabbit_email_handler, [[{port,2525},{protocol,tcp},{domain,"example.com"},{address,{0,0,0,0}}]]) at undefined exit with reason call to undefined function socket:listen(tcp, 2525, [binary,{ip,{0,0,0,0}},inet]) in context start_error

2019-05-28 19:09:25.552 [error] <0.631.0> CRASH REPORT Process <0.631.0> with 0 neighbours exited with reason: {{shutdown,{failed_to_start_child,email_handler,{undef,[{socket,listen,[tcp,2525,[binary,{ip,{0,0,0,0}},inet]],[]},{gen_smtp_server,extract_listener,2,[{file,"src/gen_smtp_server.erl"},{line,149}]},{gen_smtp_server,'-init/1-lc$^0/1-0-',2,[{file,"src/gen_smtp_server.erl"},{line,129}]},{gen_smtp_server,init,1,[{file,"src/gen_smtp_server.erl"},{line,129}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},{proc_lib,init_p_do_apply,...}]}}},...} in application_master:init/4 line 138

2019-05-28 19:09:25.562 [info] <0.43.0> Application rabbitmq_email exited with reason: {{shutdown,{failed_to_start_child,email_handler,{undef,[{socket,listen,[tcp,2525,[binary,{ip,{0,0,0,0}},inet]],[]},{gen_smtp_server,extract_listener,2,[{file,"src/gen_smtp_server.erl"},{line,149}]},{gen_smtp_server,'-init/1-lc$^0/1-0-',2,[{file,"src/gen_smtp_server.erl"},{line,129}]},{gen_smtp_server,init,1,[{file,"src/gen_smtp_server.erl"},{line,129}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},{proc_lib,init_p_do_apply,...}]}}},...}

2019-05-28 19:09:25.565 [info] <0.43.0> Application gen_smtp exited with reason: stopped
`

config:
`
[
{loopback_users,[]},
{rabbitmq_email, [
{server_config, [
[{port, 2525}, {protocol, tcp}, {domain, "example.com"}, {address,{0,0,0,0}}]
]},
{server_auth, rabbitmq},
{server_starttls, true},
{email_domains,[{<<"example.com">>, {<<"/">>, <<"email-in">>}}]},
{email_queues, [{{<<"/">>, <<"email-out">>}, <<"example.com">>}]},

    {email_from, <<"noreply">>},
    {client_sender, "taxi-rabbit@example.com"},
    {client_config, [
            {relay, "smtp.gmail.com"},
            {username, "taxi-rabbit@example.com"},
            {password, "SomePassword"},
            {auth, always},
            {ssl, true},
            {tls, if_available}
    ]}
 ]}

].
`

@zabralex85
Copy link
Author

RabbitMQ 3.7.15 ; Erlang 22.0.1

@zabralex85
Copy link
Author

If need - can redirect flow of mail to rabbit smtp. how i can start using, what's the question...

@gotthardp
Copy link
Owner

I believe this is due to incompatibility of an internal dependency (gen_smtp) with Erlang 22. (Reported and fixed Apr,4: gen-smtp/gen_smtp#168.)
Quick fix is to use the Erlang 21.x, longer fix is to compile rabbitmq-email with the latest gen_smtp.

@zabralex85
Copy link
Author

will check tnx.

@gotthardp
Copy link
Owner

The build is using my fork, which was set to an old version. I just sync-ed the fork with the gen_smtp 0.14.0, which means that the "longer fix" (rebuild) shall work now.

@zabralex85
Copy link
Author

it's very hard on vm not in docker do downgrade, which branch i need clone and compile? 3.7 ?

@zabralex85
Copy link
Author

reinstall plugins with git clone and make command + make dist

2019-05-29 14:31:10.126 [info] <0.8.0> Server startup complete; 4 plugins started.

  • rabbitmq_email
  • rabbitmq_management
  • rabbitmq_management_agent
  • rabbitmq_web_dispatch

see queue for outgoing letters, where email-in ?

@zabralex85
Copy link
Author

Am i right that queue "email-in" it's for domain example.com users?

So if i send to rabbit smtp server message to someone@example.com it will be in this queue or alternative exchange and plugin does not go by schedule to gmail to collect letters and place to queue ?

@gotthardp
Copy link
Owner

Yes, under rabbitmq_email.email_domains you define an exchange, where the plugin will forward e-mails sent to a particular domain. It supports SMTP only, so you need an own domain with own MX record. Other protocols (IMAP, POP3) that could collect letters from mailboxes are not supported.

@gotthardp gotthardp changed the title Can't enable plugin Can't enable plugin under Erlang 22 May 29, 2019
@zabralex85
Copy link
Author

got domain example-server.com add mx set.
added routing rule on google from taxi-rabbit@example.com => taxi-rabbit@example-server.com

[
{loopback_users,[]},
{rabbitmq_email, [
{server_config, [
[{port, 2525}, {protocol, tcp}, {domain, "example-server.com"}, {address,{0,0,0,0}}]
]},
{server_auth, rabbitmq},
{server_starttls, true},
{email_domains,[{<<"example-server.com">>, {<<"/">>, <<"email-in">>}}]},
{email_queues, [{{<<"/">>, <<"email-out">>}, <<"example-server.com">>}]},

    {email_from, <<"noreply">>},
    {client_sender, "taxi-rabbit@example.com"},
    {client_config, [
            {relay, "smtp.gmail.com"},
            {username, "taxi-rabbit@example.com"},
            {password, "taxi-rabbit"},
            {auth, always},
            {ssl, true},
            {tls, if_available}
    ]}
 ]}

].

@zabralex85
Copy link
Author

queue "email-in" is not shown, sended letter to mailbox.

@zabralex85
Copy link
Author

019-05-30 16:19:27.524 [info] <0.410.0> started TCP listener on [::]:5672
2019-05-30 16:19:27.524 [info] <0.291.0> Running boot step direct_client defined by app rabbit
2019-05-30 16:19:27.556 [info] <0.460.0> Management plugin: HTTP (non-TLS) listener started on port 15672
2019-05-30 16:19:27.556 [info] <0.566.0> Statistics database started.
2019-05-30 16:19:27.556 [warning] <0.576.0> iconv not detected: content transcoding is DISABLED
2019-05-30 16:19:27.557 [info] <0.577.0> gen_smtp_server starting at rabbit@main
2019-05-30 16:19:27.557 [info] <0.577.0> gen_smtp_server listening on {0,0,0,0}:2525 via tcp
2019-05-30 16:19:27.619 [notice] <0.105.0> Changed loghwm of /var/log/rabbitmq/rabbit@main.log to 50
2019-05-30 16:19:27.870 [info] <0.8.0> Server startup complete; 4 plugins started.

@zabralex85
Copy link
Author

Maybe i need mail server setup on this server ? postfix/dovecot etc ...

@lukebakken
Copy link
Collaborator

Maybe i need mail server setup on this server ? postfix/dovecot etc

No, you don't. What happens when you use the mail program or a test program to send email to port 2525? What happens when you telnet to port 2525? You can send basic SMTP commands using telnet, like HELO.

@zabralex85
Copy link
Author

zabralex85@main:~$ python smtp.py
Traceback (most recent call last):
File "smtp.py", line 18, in
server.sendmail(FROM, [TO], BODY)
File "/usr/lib/python2.7/smtplib.py", line 737, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (530, 'SMTP authentication is required', 'taxi-rabbit@example-server.com')

@zabralex85
Copy link
Author

changed auth to false and see in exchanges:
"Exchange: email-in"

@gotthardp
Copy link
Owner

Please note also that standard SMTP servers listen on port 25, so if you want to receive e-mails directly from public intenet you need to listen on the port 25, or setup iptables to redirect 25 to 2525.

@zabralex85
Copy link
Author

hmm i thought that message will be in queue ...

@zabralex85
Copy link
Author

Sender => Google Mail => Routing => My Server (MX, Static IP) => rabbitmq_email => queue

@zabralex85
Copy link
Author

In common case i want to convert mailbox to queue.

@zabralex85
Copy link
Author

zabralex85 commented May 31, 2019

cause my reader made on C# and connects to queue:

using (var channel = _persistentConnection.CreateModel()) { channel.QueueBind(queue: _queueName, exchange: BROKER_NAME, routingKey: eventName); }

@zabralex85
Copy link
Author

created queue email-int-in
added binding in section "Add binding from this exchange" in dashboard ....

@zabralex85
Copy link
Author

If i send frequently i see that graph of "Publish (in)" is growing but nothing in queue

@zabralex85
Copy link
Author

zabralex85 commented May 31, 2019

in logs i see:

2019-05-31 05:03:50.848 [info] <0.4694.0> example-server.com SMTP connection from {127,0,0,1}
2019-05-31 05:03:50.854 [info] <0.4694.0> EHLO from main.us-west2-a.c.engaged-truth-230123.internal
2019-05-31 05:03:50.856 [info] <0.4694.0> text/plain message from zabralex85@gmail.com to [<<"taxi-rabbit@example-sever.com">>] queued as 344099c3d58952819c37b5d74f580776

@zabralex85
Copy link
Author

script to send:

import smtplib

HOST = "localhost"
PORT = 2525
SUBJECT = "Test email from Python"
TO = "taxi-rabbit@example-server.com"
FROM = "zabralex85@gmail.com"
text = "Python 3.4 rules them all!"

BODY = "\r\n".join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT ,
"",
text
))

server = smtplib.SMTP(HOST, PORT)
server.sendmail(FROM, [TO], BODY)
server.quit()

@zabralex85
Copy link
Author

if i publish message to exchange in dasboard it goes to queue ...

@gotthardp
Copy link
Owner

I guess the queue to exchange binding does not match the routing key
https://github.com/gotthardp/rabbitmq-email#smtp-to-amqp-0-9-1-conversion-workflow

You can use a fanout exchange, or a topic with * binding to make sure all e-mails go to a queue.

@zabralex85
Copy link
Author

image
image

@zabralex85
Copy link
Author

i have no vhosts - default setup ... it's matter?

@gotthardp
Copy link
Owner

I believe you will always have at least the default vhost /. I can see a topic exchange named email-in bound to an empty string. Such setup will not deliver any e-mails to the email-int-in, just as you experienced.
Then there is a default fanout exchange named amq.fanout, which will work when you configure it in your {email_domains,[{<<"example-server.com">>, {<<"/">>, <<"amq.fanout">>}}]},.

@zabralex85
Copy link
Author

understood - think you can close issue.

@michaelklishin
Copy link
Collaborator

FTR, the default virtual host can be renamed to be anything other than / and can be deleted (many RabbitMQ-as-a-Service products do that, for example).

@ergoz
Copy link

ergoz commented Jul 9, 2019

i have same problem with RabbitMQ 3.7.16
I tried to build rabbitmq_email with eiconv=1 - but while build it says that no makefile for eiconv (i need it to support russian language). If i build without eiconv - it builds but when i try to enable plugin:

2019-07-09 19:18:49.287175 std_error           #{label=>{erl_prim_loader,file_error},report=>"File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/gen_smtp-0.14.0.ez/ebin. Function: read_file_info. Process: code_server."}
#{label=>{erl_prim_loader,file_error},report=2019-07-09 19:18:49.294244 std_error           >"File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/gen_smtp-0.14.0.ez/gen_smtp/ebin. Function: read_file_info. Process: code_server."}
2019-07-09 19:18:49.295700 std_error         #{label=  >{erl_prim_loader,file_error},report=>"File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/gen_smtp-0.14.0.ez/gen_smtp-0.14.0/ebin. Function: read_file_info. Process: code_server."}
2019-07-09 19:18:49.316286 std_error           #{label=>{erl_prim_loader,file_error},report=>"File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/rabbitmq_email-0.3.0.ez/ebin. Function: read_file_info. Process: code_server."}
2019-07-09 19:18:49.317848 std_error         #{label=>{er  l_prim_loader,file_error},report=>"File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/rabbitmq_email-0.3.0.ez/rabbitmq_email/ebin. Function: read_file_info. Process: code_server."}
2019-07-09 19:18:49.321231 std_error           #{label=>{erl_prim_loader,file_error},report=>"File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/rabbitmq_email-0.3.0.ez/rabbitmq_email-0.3.0/ebin. Function: read_file_info. Process: code_server."}
=ERROR REPORT==== 9-Jul-2019::19:18:49.287175 ===
File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/gen_smtp-0.14.0.ez/ebin. Function: read_file_info. Process: code_server.
=ERROR REPORT==== 9-Jul-2019::19:18:49.294244 ===
File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/gen_smtp-0.14.0.ez/gen_smtp/ebin. Function: read_file_info. Process: code_server.
=ERROR REPORT==== 9-Jul-2019::19:18:49.295700 ===
File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/gen_smtp-0.14.0.ez/gen_smtp-0.14.0/ebin. Function: read_file_info. Process: code_server.
=ERROR REPORT==== 9-Jul-2019::19:18:49.316286 ===
File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/rabbitmq_email-0.3.0.ez/ebin. Function: read_file_info. Process: code_server.
=ERROR REPORT==== 9-Jul-2019::19:18:49.317848 ===
File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/rabbitmq_email-0.3.0.ez/rabbitmq_email/ebin. Function: read_file_info. Process: code_server.
=ERROR REPORT==== 9-Jul-2019::19:18:49.321231 ===
File operation error: bad_eocd. Target: /opt/rabbitmq/plugins/rabbitmq_email-0.3.0.ez/rabbitmq_email-0.3.0/ebin. Function: read_file_info. Process: code_server.

@gotthardp gotthardp will you release new version to fix this pain? :)
Заранее спасибо :)

@gotthardp
Copy link
Owner

@ergoz, please don't piggyback old issues. Releases with eiconv create target CPU dependency, so they cannot be released via the standard process and published. If you need eiconv, I suggest you open a new issue for the failing eiconv build.

@ergoz
Copy link

ergoz commented Aug 22, 2019

@gotthardp read my message fully, please. I have problem with plugin if i build without eiconv too! I posted log with it. My problem not in eiconv, my problem firstly in what in log.

@gotthardp
Copy link
Owner

@ergoz, please don't reuse old issues. You said you needed eiconv, so I saw no point in trying to build it witout it.

The bad_eocd error indicates the package was built incorrectly or was damaged after. There is not much I can do other than recommending to follow the build instructions.

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

No branches or pull requests

5 participants