gotthardp / rabbitmq-email

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

Messages are stuck in queue? #32

Closed Zalarox closed 3 years ago

Zalarox commented 6 years ago

Hi, I'm new to rabbitmq and am trying to set up a very basic flow to send an email to an external domain.

RabbitMQ 3.7.2 with rabbitmq_email-0.2.0 and gen_smtp-0.12.0 on a Windows 7 64-bit system. As instructed in the read me, I can set up an exchange and a queue, and publish a message which is successfully queued according to the RabbitMQ manager.

However, these messages are never processed. Clearly there is something fundamental that I'm misunderstanding.

I'm using the default config file provided in the read me (albeit with my exchange name rather than "X").

Here's my code snippet:

import pika

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='email-out')

channel.exchange_declare(exchange='email-in', exchange_type='topic')
channel.queue_bind(exchange='email-in', queue='email-out', routing_key='me@example.com')

channel.basic_publish(exchange='email-in',
    routing_key='me@example.com',
    properties=pika.BasicProperties(
        content_type = 'text/plain',
        headers = {'Subject':'Greetings'}),
    body='Hello world!')
connection.close()

What needs to be done to actually send the mails? I've tried messing around with the hosted SMTP server using telnet, but that doesn't seem to be able to queue my mails at all.

220 example.com ESMTP rabbit_email_handler
EHLO example.com
250-example.com
250-AUTH PLAIN LOGIN
250-SIZE 10485670
250-8BITMIME
250 PIPELINING
AUTH LOGIN
334 VXNlcm5hbWU6
Z3Vlc3Q=
334 UGFzc3dvcmQ6
Z3Vlc3Q=
235 Authentication successful.
MAIL FROM: me@example.com
250 sender Ok
RCPT TO: personalemail@gmail.com
250 recipient Ok
DATA
354 enter mail, end with line containing only '.'
hello world
.

Apparently the delimiter is not detected?... Sending mails works just fine using SMTPlib and another locally hosted SMTP server (hMailServer) on a different port. What am I doing wrong?

lukebakken commented 6 years ago

Hello -

Zalarox commented 6 years ago

Hi @lukebakken - thanks for the response!

Erlang Version: OTP 20.2 I'm attaching the RabbitMQ configuration and server logs as a zip file to this response.

Forgive me if I'm missing out on something here but isn't this line binding the email-out queue to the email-in exchange? Perhaps I'm doing something wrong with the routing keys?

channel.queue_bind(exchange='email-in', queue='email-out', routing_key='me@example.com')

files.zip

Thanks once again for your help!

lukebakken commented 3 years ago

My guess is that this is due to the fact that you are not defining an SMTP relay. You still have the following in your configuration file:

{relay, "smtp.example.com"}