gotthardp / rabbitmq-email

SMTP Gateway Plugin for RabbitMQ
Mozilla Public License 2.0
181 stars 20 forks source link

Can't receive any email from google #14

Closed ru-sh closed 8 years ago

ru-sh commented 8 years ago

Log of tcp communication:

Sat, 09 Jan 2016 19:59:16 GMT socket connected: ::ffff:209.85.215.45

Sat, 09 Jan 2016 19:59:16 GMT downstream data: 220 pmr.social ESMTP rabbit_email_handler

Sat, 09 Jan 2016 19:59:16 GMT upstream data: EHLO mail-lf0-f45.google.com

Sat, 09 Jan 2016 19:59:16 GMT downstream data: 250-pmr.social 250-STARTTLS 250-SIZE 10485670 250-8BITMIME 250 PIPELINING

Sat, 09 Jan 2016 19:59:16 GMT upstream data: STARTTLS

Sat, 09 Jan 2016 19:59:16 GMT downstream data: 220 OK

Sat, 09 Jan 2016 19:59:16 GMT outgoing socket closed

Sat, 09 Jan 2016 19:59:16 GMT incoming socket closed

ru-sh commented 8 years ago

RabbitMq config:

[{rabbitmq_email, [
    % gen_smtp server parameters
    % see https://github.com/Vagabond/gen_smtp#server-example
    {server_config, [
        [{port, 2525}, {protocol, tcp}, {domain, "pmr.social"}, {address,{0,0,0,0}}]
    ]},
    % how clients are authenticated; either 'false' or 'rabbitmq' (default)
    {server_auth, false},
    % whether STARTTLS shall be offered; either 'true' or 'false' (default)
    {server_starttls, true},
    % inbound email exchanges: [{email-domain, {vhost, exchange}}, ...}
    {email_domains,
        [{<<"pmr.social">>, {<<"/">>, <<"email-in">>}}
    ]},

    % outbound email queues: [{{vhost, queue}, email-domain}, ...]
    {email_queues,
        [{{<<"/">>, <<"email-out">>}, <<"example.com">>}
    ]},
    % sender indicated in the From header
    {client_sender, "noreply@example.com"},
    % gen_smtp client parameters
    % see https://github.com/Vagabond/gen_smtp#client-example
    {client_config, [
    ]}
]},{rabbit, [{loopback_users, []}]}].
gotthardp commented 8 years ago

I suspect the TLS might be an issue. Would you be able to inspect the traffic using Wireshark? Was there some TLS handshake after sending OK to the STARTTLS?

ru-sh commented 8 years ago

root@ubuntu:~# tshark -i eth0 -f "dst port 25" tshark: Lua: Error during loading: [string "/usr/share/wireshark/init.lua"]:46: dofile has been disabled due to running Wireshark as superuser. See http://wiki.wireshark.org/CaptureSetup/CapturePrivileges for help in running Wireshark as an unprivileged user. Running as user "root" and group "root". This could be dangerous. Capturing on 'eth0' 1 0.000000 209.85.217.176 -> 188.166.71.187 TCP 74 32807 > smtp [SYN] Seq=0 Win=42900 Len=0 MSS=1430 SACK_PERM=1 TSval=2856431074 TSecr=0 WS=128 2 0.035095 209.85.217.176 -> 188.166.71.187 TCP 66 32807 > smtp [ACK] Seq=1 Ack=1 Win=43008 Len=0 TSval=2856431109 TSecr=73821045 3 0.078514 209.85.217.176 -> 188.166.71.187 TCP 66 32807 > smtp [ACK] Seq=1 Ack=44 Win=43008 Len=0 TSval=2856431153 TSecr=73821056 3 4 0.078574 209.85.217.176 -> 188.166.71.187 SMTP 97 C: EHLO mail-lb0-f176.google.com 5 0.114934 209.85.217.176 -> 188.166.71.187 SMTP 115 C: MAIL FROM:shakirov.ruslan@gmail.com SIZE=1476 6 0.115001 209.85.217.176 -> 188.166.71.187 SMTP 90 C: RCPT TO:a@pmr.social 7 0.115008 209.85.217.176 -> 188.166.71.187 SMTP 72 C: DATA 8 0.189232 209.85.217.176 -> 188.166.71.187 TCP 66 32807 > smtp [ACK] Seq=111 Ack=146 Win=43008 Len=0 TSval=2856431264 TSecr=73821074 9 0.224010 209.85.217.176 -> 188.166.71.187 TCP 66 32807 > smtp [ACK] Seq=111 Ack=213 Win=43008 Len=0 TSval=2856431298 TSecr=73821093 10 0.224221 209.85.217.176 -> 188.166.71.187 SMTP 72 C: DATA fragment, 6 bytes 11 0.224269 209.85.217.176 -> 188.166.71.187 TCP 66 32807 > smtp [FIN, ACK] Seq=117 Ack=213 Win=43008 Len=0 TSval=2856431299 TSecr=73821093 12 0.259313 209.85.217.176 -> 188.166.71.187 TCP 60 32807 > smtp [RST] Seq=118 Win=0 Len=0 13 0.259405 209.85.217.176 -> 188.166.71.187 TCP 60 32807 > smtp [RST] Seq=118 Win=0 Len=0

gotthardp commented 8 years ago

This looks fine. Could you share with me also the RabbitMQ log file?

ru-sh commented 8 years ago

=INFO REPORT==== 12-Jan-2016::00:25:57 === pmr.social SMTP connection from {209,85,217,169}

=INFO REPORT==== 12-Jan-2016::00:25:57 === EHLO from mail-lb0-f169.google.com

=INFO REPORT==== 12-Jan-2016::09:24:54 === pmr.social SMTP connection from {89,248,160,196}

=INFO REPORT==== 12-Jan-2016::09:24:54 === EHLO from masscan

=INFO REPORT==== 12-Jan-2016::12:20:06 === pmr.social SMTP connection from {209,85,215,44}

=INFO REPORT==== 12-Jan-2016::12:20:06 === EHLO from mail-lf0-f44.google.com

=INFO REPORT==== 12-Jan-2016::18:58:09 === pmr.social SMTP connection from {209,85,215,45}

=INFO REPORT==== 12-Jan-2016::18:58:09 === EHLO from mail-lf0-f45.google.com

gotthardp commented 8 years ago

This is needs more debugging. Would you mind sending the same email to rabbitmq@swimgate.eu? It's my test instance of the plugin.

ru-sh commented 8 years ago

I send it now.

gotthardp commented 8 years ago

Thanks. It arrived and was processed as expected. What version of rabbitmq and the plugin are you using?

ru-sh commented 8 years ago

I trying to setup a docker container. My docker image (https://github.com/ru-sh/RabbitMqSmtp) is based on latest rabbitmq image (version 3.6.0, https://hub.docker.com/_/rabbitmq/).

gotthardp commented 8 years ago

Hello. I did some more tests, but still wasn;t able to reproduce your problem. However, I added some more logs. Would you mind get the latest sources, re-build and re-test the plugin?

ru-sh commented 8 years ago

Yes. I get this error when I try to build last sources:

ERLC app_utils.erl credit_flow.erl gen_server2.erl mirrored_supervisor.erl mochijson2.erl pmon.erl priority_queue.erl rabbit_amqqueue.erl rabbit_auth_mechanism.erl rabbit_authn_backend.erl rabbit_authz_backend.erl rabbit_backing_queue.erl rabbit_basic.erl rabbit_binary_generator.erl rabbit_binary_parser.erl rabbit_channel.erl rabbit_channel_interceptor.erl rabbit_command_assembler.erl rabbit_control_misc.erl rabbit_data_coercion.erl rabbit_event.erl rabbit_exchange_decorator.erl rabbit_exchange_type.erl rabbit_framing_amqp_0_8.erl rabbit_framing_amqp_0_9_1.erl rabbit_heartbeat.erl rabbit_misc.erl rabbit_msg_store_index.erl rabbit_net.erl rabbit_networking.erl rabbit_nodes.erl rabbit_password_hashing.erl rabbit_policy_validator.erl rabbit_queue_collector.erl rabbit_queue_decorator.erl rabbit_queue_master_locator.erl rabbit_reader.erl rabbit_runtime_parameter.erl rabbit_writer.erl ssl_compat.erl supervisor2.erl time_compat.erl src/rabbit_net.erl:27: can't find include lib "ssl/src/ssl_api.hrl" src/rabbit_net.erl:101: record sslsocket undefined src/rabbit_net.erl:111: record sslsocket undefined src/rabbit_net.erl:116: record sslsocket undefined src/rabbit_net.erl:121: record sslsocket undefined src/rabbit_net.erl:126: record sslsocket undefined src/rabbit_net.erl:139: record sslsocket undefined src/rabbit_net.erl:144: record sslsocket undefined src/rabbit_net.erl:158: record sslsocket undefined src/rabbit_net.erl:167: record sslsocket undefined src/rabbit_net.erl:172: record sslsocket undefined src/rabbit_net.erl:177: record sslsocket undefined src/rabbit_net.erl:180: record sslsocket undefined src/rabbit_net.erl:183: record sslsocket undefined src/rabbit_net.erl:209: record sslsocket undefined src/rabbit_net.erl:212: record sslsocket undefined src/rabbit_net.erl:215: record sslsocket undefined src/rabbit_net.erl:253: record sslsocket undefined erlang.mk:4971: recipe for target 'ebin/rabbit_common.app' failed make[3]: * [ebin/rabbit_common.app] Error 1 erlang.mk:4807: recipe for target 'app' failed make[2]: * [app] Error 2 make[2]: Leaving directory '/rabbitmq-email/deps/rabbit_common' erlang.mk:4066: recipe for target 'deps' failed make[1]: * [deps] Error 2 make[1]: Leaving directory '/rabbitmq-email/deps/amqp_client' erlang.mk:4066: recipe for target 'deps' failed make: * [deps] Error 2 The command '/bin/sh -c make dist' returned a non-zero code: 2

michaelklishin commented 8 years ago

See https://github.com/rabbitmq/rabbitmq-common/issues/27.

ru-sh commented 8 years ago

Thank you!

ru-sh commented 8 years ago

It work if 'server_starttls' is set to 'false' and it don't work if starttls is set to true. I think it will be better to use nginx/apache proxy to get encrypted smtp connection. So my problem is solved.

Thank you for all your assistance!

michaelklishin commented 8 years ago

Perhaps file a new issue now that we understand the problem better?