gotthardp/rabbitmq-email

Create rabbitmq.config

DrMartiner opened this issue · 7 comments

I want to sent email via postfix. Help me please to configure rabbitmq.config. My config:

[
  {rabbitmq_email, [
    {server_config, [
        [{port, 2525}, {protocol, tcp}, {domain, "yandex.ru"}, {address,{0,0,0,0}}]
    ]},
    {server_auth, rabbitmq},
    {server_starttls, true},
    {email_domains,
        [{<<"yandex.ru">>, {<<"/">>, <<"email-in">>}}
    ]},
    {email_queues,
        [{{<<"/">>, <<"email-out">>}, <<"yandex.ru">>}
    ]},
    {client_sender, "user6611@yandex.ru"},
    {client_config, [
        {relay, "smtp.yandex.ru"}
    ]}
  ]}
].

If I published in 'email-out' queue and didn't received:

MESSAGE = MIMEMultipart('alternative')
MESSAGE['subject'] = 'Test message'
msg_text = 'Helo, World!'
MESSAGE['To'] = 'drmartiner@gmail.com'
MESSAGE['From'] = 'user6611@yandex.ru'
MESSAGE.preamble = """preamble"""
HTML_BODY = MIMEText(msg_text, 'plain', "utf-8")
MESSAGE.attach(HTML_BODY)

channel.exchange_declare(exchange='X', type='topic')
channel.queue_bind(exchange='X', queue='email-out', routing_key='#')

channel.basic_publish(exchange='X',
                      routing_key='yandex.ru',
                      body=MESSAGE.as_string())

PS: echo "test" | mutt -s "test" drmartiner@gmail.com - it working

So what is your question?

I can't send via publish message. What are problem?

A similar question is asked here #13. Please try something like this first:

channel.basic_publish(exchange='X',
                      routing_key='drmartiner@gmail.com',
                      body='Hello world.')

Don't put any MIME headers in the AMQP message.

@DrMartiner sorry but "I can't send email" is not specific enough. Engineers need more information to work with or suggest anything: what errors do you see in the log? Does sending email work with any other configuration? and so on.

Please respect the maintainer's time and provide more information if you want to get help.

@michaelklishin I configure Postfix (I can sending message: echo "test" | mutt -s "test" drmartiner@gmail.com), I configure Rabbit MQ, I try to send message via rabbit's plugin and it doesn't work...

When I sent email from bash I got it logs:

Jan 13 08:38:07 vagrant-ubuntu-trusty-32 postfix/pickup[22473]: 4A57B423E2: uid=0 from=<root>
Jan 13 08:38:07 vagrant-ubuntu-trusty-32 postfix/cleanup[23240]: 4A57B423E2: message-id=<20160113083807.GA23229@vagrant-ubuntu-trusty-32>
Jan 13 08:38:07 vagrant-ubuntu-trusty-32 postfix/qmgr[18658]: 4A57B423E2: from=<root@vagrant-ubuntu-trusty-32.localdomain>, size=468, nrcpt=1 (queue active)
Jan 13 08:38:09 vagrant-ubuntu-trusty-32 postfix/smtp[23242]: 4A57B423E2: to=<drmartiner@gmail.com>, relay=gmail-smtp-in.l.google.com[11.24.43.19]:25, delay=1.9, delays=0.05/0.02/1.5/0.28, dsn=2.0.0, status=sent (250 2.0.0 OK 1452674288 xv9si150696lbb.38 - gsmtp)
Jan 13 08:38:09 vagrant-ubuntu-trusty-32 postfix/qmgr[18658]: 4A57B423E2: removed

but when I put message to the queue, log records was not appended. Where I mistake in configures files or Python's codes?

@gotthardp I did it, but it doesn't work: I haven't got new log's records in /var/log/mail.log =(

Hi again. I created set of Python examples that work for me. Please check the README.md and let me know if it worked for you.