gotthardp / rabbitmq-email

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

How to create AMQP header if i want to send MIME header? #13

Closed artemliubymov closed 3 years ago

artemliubymov commented 8 years ago

Hello again!:) I configured in properities content-type and headers, but email not send and in log was error. Code python:

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

 me = 'test.ekadastr@yandex.ru'
 you = 'ArtemLiubymov@yandex.ru'

 MESSAGE = MIMEMultipart('alternative')
 MESSAGE['subject'] = 'Hello'
 msg_text = 'helllo woooooooooooorld'
 MESSAGE['To'] = you
 MESSAGE['From'] = me
 MESSAGE.preamble = """"""
 HTML_BODY = MIMEText(msg_text, 'plain', "utf-8")
 MESSAGE.attach(HTML_BODY)

s = smtplib.SMTP('localhost', 2525)
s.login("guest", "guest")
channel.exchange_declare(exchange='X', type='topic')
channel.queue_bind(exchange='X', queue='email-out', routing_key='#')

channel.basic_publish(exchange='X',
              routing_key='ArtemLiubymov@yandex.ru',
              body=MESSAGE.as_string(),
              properties=pika.BasicProperties(
                 delivery_mode = 2, # make message persistent
         content_type = 'text/plain',
                 headers = {'header':'Hello'}
              ))        

s.sendmail(me, you, MESSAGE.as_string())

Error in log:

 =ERROR REPORT==== 7-Jan-2016::18:53:58 ===
 ** Generic server <0.17757.2> terminating
 ** Last message in was {consumer_call,
                       {'basic.deliver',<<"example.com">>,2,false,
                           <<"X">>,<<"ArtemLiubymov@yandex.ru">>},
                       {amqp_msg,
                           {'P_basic',<<"text/plain">>,undefined,
                               [{<<"header">>,longstr,<<"Hello">>}],
                               2,undefined,undefined,undefined,undefined,
                               undefined,undefined,undefined,undefined,
                               undefined,undefined},
                           <<"Content-Type: multipart/alternative;  
  boundary=\"===============8461060884206808169==\"\nMIME-Version: 1.0\nsubject:   
  Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n--  
  ===============8461060884206808169==\nContent-Type: text/plain; charset=\"utf-8\"\nMIME-  
   Version: 1.0\nContent-Transfer-Encoding:   
   base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
   ===============8461060884206808169==--\n">>}}
    ** When Server state == {state,amqp_selective_consumer,
                        {state,
                            {dict,0,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 [],[],[]},
                                {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                  [],[],[]}}},
                            undefined,
                            {dict,0,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 [],[],[]},
                                {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                  [],[],[]}}},
                            none}}
  ** Reason for termination == 
   ** unexpected_delivery_and_no_default_consumer

    =INFO REPORT==== 7-Jan-2016::18:53:58 ===
      text/plain message from test.ekadastr@yandex.ru to [<<"ArtemLiubymov@yandex.ru">>]   
      queued as 6b194ea079e30c74d98438a77c8e3779

     =INFO REPORT==== 7-Jan-2016::18:53:58 ===
    {'EXIT',<0.17969.2>,normal}

If in code i change

  content_type = 'text/plain' 

to

  content_type = 'multitype/alternative'

then no error in log but email not send. What i wrong configured?

gotthardp commented 8 years ago

To set a MIME header, just put them in the list of AMQP headers

channel.basic_publish(exchange='X',
              routing_key='ArtemLiubymov@yandex.ru',
              body=MESSAGE.as_string(),
              properties=pika.BasicProperties(
                 delivery_mode = 2, # make message persistent
                 content_type = 'text/plain',
                 headers = {'subject':'Hello world',
                            'date':'7.1.2016'}
              ))
artemliubymov commented 8 years ago

I change headers to yours, but when i first run code in log all OK,but email not send, and when i run again it was error in log. Test log:

     =INFO REPORT==== 7-Jan-2016::19:29:19 ===
     accepting AMQP connection <0.18462.2> (127.0.0.1:56901 -> 127.0.0.1:5672)

      =INFO REPORT==== 7-Jan-2016::19:29:19 ===
     example.com SMTP connection from {127,0,0,1}

     =INFO REPORT==== 7-Jan-2016::19:29:19 ===
     EHLO from [127.0.0.1]

    =INFO REPORT==== 7-Jan-2016::19:29:19 ===
    sending <<"text">>/<<"plain">> e-mail to <<"ArtemLiubymov@yandex.ru">>

    =INFO REPORT==== 7-Jan-2016::19:29:19 ===
     text/plain message from test.ekadastr@yandex.ru to [<<"ArtemLiubymov@yandex.ru">>] queued  
     as 61fdc55fc1af7653bf1b1e62448d5925

     =INFO REPORT==== 7-Jan-2016::19:29:19 ===
     {'EXIT',<0.18493.2>,normal}

    =INFO REPORT==== 7-Jan-2016::19:29:19 ===
    closing AMQP connection <0.18462.2> (127.0.0.1:56901 -> 127.0.0.1:5672)

   =INFO REPORT==== 7-Jan-2016::19:31:27 ===
   accepting AMQP connection <0.18534.2> (127.0.0.1:56929 -> 127.0.0.1:5672)

  =INFO REPORT==== 7-Jan-2016::19:31:27 ===
   example.com SMTP connection from {127,0,0,1}

  =INFO REPORT==== 7-Jan-2016::19:31:27 ===
   EHLO from [127.0.0.1]

  =ERROR REPORT==== 7-Jan-2016::19:31:27 ===
  ** Generic server <0.18409.2> terminating
  ** Last message in was {consumer_call,
                       {'basic.deliver',<<"example.com">>,2,false,
                           <<"X">>,<<"ArtemLiubymov@yandex.ru">>},
                       {amqp_msg,
                           {'P_basic',<<"text/plain">>,undefined,
                               [{<<"date">>,longstr,<<"7.1.2016">>},
                                {<<"subject">>,longstr,<<"Hello">>}],
                               2,undefined,undefined,undefined,undefined,
                               undefined,undefined,undefined,undefined,
                               undefined,undefined},
                           <<"Content-Type: multipart/alternative;   
     boundary=\"===============8079216572910437759==\"\nMIME-Version: 1.0\nsubject:  
      Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n-- 
   ===============8079216572910437759==\nContent-Type: text/plain; charset=\"utf-8\"\nMIME- 
    Version: 1.0\nContent-Transfer-Encoding:  
     base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
      ===============8079216572910437759==--\n">>}}
     ** When Server state == {state,amqp_selective_consumer,
                        {state,
                            {dict,0,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 [],[],[]},
                                {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                  [],[],[]}}},
                            undefined,
                            {dict,0,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 [],[],[]},
                                {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                  [],[],[]}}},
                            none}}
 ** Reason for termination == 
 ** unexpected_delivery_and_no_default_consumer

 =ERROR REPORT==== 7-Jan-2016::19:31:27 ===
  ** Generic server <0.18410.2> terminating 
 ** Last message in was {send_command_and_notify,<0.236.0>,<0.18413.2>,
                       {'basic.deliver',<<"example.com">>,2,false,
                           <<"X">>,<<"ArtemLiubymov@yandex.ru">>},
                       {content,60,
                           {'P_basic',<<"text/plain">>,undefined,
                               [{<<"date">>,longstr,<<"7.1.2016">>},
                                {<<"subject">>,longstr,<<"Hello">>}],
                               2,undefined,undefined,undefined,undefined,
                               undefined,undefined,undefined,undefined,
                               undefined,undefined},
                           <<176,0,10,116,101,120,116,47,112,108,97,105,
                             110,0,0,0,36,4,100,97,116,101,83,0,0,0,8,55,
                             46,49,46,50,48,49,54,7,115,117,98,106,101,99,
                             116,83,0,0,0,5,72,101,108,108,111,2>>,
                           rabbit_framing_amqp_0_9_1,
                           [<<"Content-Type: multipart/alternative;         
   boundary=\"===============8079216572910437759==\"\nMIME-Version: 1.0\nsubject:  
   Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n- -     
   ===============8079216572910437759==\nContent-Type: text/plain; charset=\"utf-8\"\nMIME- 
   Version: 1.0\nContent-Transfer-Encoding:  
   base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
   ===============8079216572910437759==--\n">>]}}
   ** When Server state == {state,1,<0.18398.2>,<0.18409.2>,direct,
                           {[],[]},
                           false,<0.18413.2>,none,none,0,true,none,
                           {0,nil},
                           {0,nil},
                           true,false}
    ** Reason for termination == 
   ** {{unexpected_delivery_and_no_default_consumer,
    {gen_server2,call,
        [<0.18409.2>,
         {consumer_call,
             {'basic.deliver',<<"example.com">>,2,false,<<"X">>,
                 <<"ArtemLiubymov@yandex.ru">>},
             {amqp_msg,
                 {'P_basic',<<"text/plain">>,undefined,
                     [{<<"date">>,longstr,<<"7.1.2016">>},
                      {<<"subject">>,longstr,<<"Hello">>}],
                     2,undefined,undefined,undefined,undefined,undefined,
                     undefined,undefined,undefined,undefined,undefined},
                 <<"Content-Type: multipart/alternative;  
     boundary=\"===============8079216572910437759==\"\nMIME-Version: 1.0\nsubject:  
     Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n-- 
     ===============8079216572910437759==\nContent-Type: text/plain; charset=\"utf- 
     8\"\nMIME-Version: 1.0\nContent-Transfer-Encoding:  
     base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
    ===============8079216572910437759==--\n">>}},
         infinity]}},
    [{gen_server2,call,3,[]},
      {amqp_channel,handle_method_from_server1,3,[]},
       {amqp_channel,handle_info,2,[]},
         {gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,615}]},
          {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,681}]},
            {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}

    =WARNING REPORT==== 7-Jan-2016::19:31:27 ===
     Connection (<0.18398.2>) closing: internal error in channel (<0.18410.2>):      
    {unexpected_delivery_and_no_default_consumer,
                                                                        {gen_server2,
                                                                         call,
                                                                         [<0.18409.2>,
                                                                          {consumer_call,
                                                                           {'basic.deliver',
                                                                            <<"example.com">>,
                                                                            2,
                                                                            false,
                                                                            <<"X">>,
                                                                            <<"ArtemLiubymov@yandex.ru">>},
                                                                           {amqp_msg,
                                                                            {'P_basic',
                                                                             <<"text/plain">>,
                                                                             undefined,
                                                                             [{<<"date">>,
                                                                               longstr,
                                                                               <<"7.1.2016">>},
                                                                              {<<"subject">>,
                                                                               longstr,
                                                                               <<"Hello">>}],
                                                                             2,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined,
                                                                             undefined},
                                                                            <<"Content-Type: multipart/alternative;  
   boundary=\"===============8079216572910437759==\"\nMIME-Version: 1.0\nsubject: 
   Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n--      
   ===============8079216572910437759==\nContent-Type: text/plain; charset=\"utf-8\"\nMIME- 
  Version: 1.0\nContent-Transfer-Encoding:  
    base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
   ===============8079216572910437759==--\n">>}},
                                                                          infinity]}}

   =ERROR REPORT==== 7-Jan-2016::19:31:27 ===
  ** Generic server <0.18413.2> terminating
  ** Last message in was {'EXIT',<0.18410.2>,
                    {unexpected_delivery_and_no_default_consumer,
                     {gen_server2,call,
                      [<0.18409.2>,
                       {consumer_call,
                        {'basic.deliver',<<"example.com">>,2,false,
                         <<"X">>,<<"ArtemLiubymov@yandex.ru">>},
                        {amqp_msg,
                         {'P_basic',<<"text/plain">>,undefined,
                          [{<<"date">>,longstr,<<"7.1.2016">>},
                           {<<"subject">>,longstr,<<"Hello">>}],
                          2,undefined,undefined,undefined,undefined,
                          undefined,undefined,undefined,undefined,
                          undefined,undefined},
                         <<"Content-Type: multipart/alternative; 
   boundary=\"===============8079216572910437759==\"\nMIME-Version: 1.0\nsubject: 
  Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n-- 
  ===============8079216572910437759==\nContent-Type: text/plain; charset=\"utf-8\"\nMIME- 
  Version: 1.0\nContent-Transfer-Encoding: 
  base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
   ===============8079216572910437759==--\n">>}},
                       infinity]}}}
    ** When Server state == {ch,running,rabbit_framing_amqp_0_9_1,1,<0.18410.2>,
                     <0.18410.2>,<0.18398.2>,
                     <<"<rabbit@artem-Inspiron-N5110.3.18398.2>">>,
                     {lstate,<0.18412.2>,false},
                     none,3,
                     {[],[]},
                     {user,<<"none">>,[],
                      [{rabbit_auth_backend_dummy,none}]},
                     <<"/">>,<<>>,
                     {dict,1,16,16,8,80,48,
                      {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                      {{[],[],[],[],[],[],[],[],[],[],[],[],
                        [[<0.236.0>|
                          {resource,<<"/">>,queue,<<"email-out">>}]],
                        [],[],[]}}},
                     {state,
                      {dict,1,16,16,8,80,48,
                       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                       {{[],[],[],[],[],[],[],[],[],[],[],[],
                         [[<0.236.0>|#Ref<0.0.1310721.197198>]],
                         [],[],[]}}},
                      erlang},
                     {dict,1,16,16,8,80,48,
                      {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                      {{[],[],[],[],
                        [[<<"example.com">>|
                          {{amqqueue,
                            {resource,<<"/">>,queue,<<"email-out">>},
                            true,false,none,[],<0.236.0>,[],[],[],
                            undefined,[],[],live},
                           {true,0,false,[]}}]],
                        [],[],[],[],[],[],[],[],[],[],[]}}},
                     {dict,1,16,16,8,80,48,
                      {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                      {{[],[],[],[],[],[],[],[],[],[],[],[],
                        [[<0.236.0>|{1,{<<"example.com">>,nil,nil}}]],
                        [],[],[]}}},
                     {set,0,16,16,8,80,48,
                      {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                      {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}},
                     <0.18401.2>,
                     {state,fine,5000,#Ref<0.0.1310721.198866>},
                     false,1,
                     {{0,nil},{0,nil}},
                     [],
                     {{0,nil},{0,nil}},
                     [{<<"publisher_confirms">>,bool,true},
                      {<<"exchange_exchange_bindings">>,bool,true},
                      {<<"basic.nack">>,bool,true},
                      {<<"consumer_cancel_notify">>,bool,true},
                      {<<"connection.blocked">>,bool,true},
                      {<<"authentication_failure_close">>,bool,true}],
                     none,0,none,flow}
   ** Reason for termination == 
     ** {unexpected_delivery_and_no_default_consumer,
   {gen_server2,call,
       [<0.18409.2>,
        {consumer_call,
            {'basic.deliver',<<"example.com">>,2,false,<<"X">>,
                <<"ArtemLiubymov@yandex.ru">>},
            {amqp_msg,
                {'P_basic',<<"text/plain">>,undefined,
                    [{<<"date">>,longstr,<<"7.1.2016">>},
                     {<<"subject">>,longstr,<<"Hello">>}],
                    2,undefined,undefined,undefined,undefined,undefined,
                    undefined,undefined,undefined,undefined,undefined},
                <<"Content-Type: multipart/alternative;  
    boundary=\"===============8079216572910437759==\"\nMIME-Version: 1.0\nsubject:  
    Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n-- 
   ===============8079216572910437759==\nContent-Type: text/plain; charset=\"utf-8\"\nMIME- 
  Version: 1.0\nContent-Transfer-Encoding:  
  base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n--
   ===============8079216572910437759==--\n">>}},
        infinity]}}

    =INFO REPORT==== 7-Jan-2016::19:31:27 ===
     text/plain message from test.ekadastr@yandex.ru to [<<"ArtemLiubymov@yandex.ru">>] queued  
       as  efe9cafca0442d331eeb8a2ce8168d1f

       =INFO REPORT==== 7-Jan-2016::19:31:27 ===
        {'EXIT',<0.18564.2>,normal}

       =INFO REPORT==== 7-Jan-2016::19:31:27 ===
     closing AMQP connection <0.18534.2> (127.0.0.1:56929 -> 127.0.0.1:5672)
gotthardp commented 8 years ago

Did you notice that the e-mail was likely looped back to the broker? It looks like it was sent.

artemliubymov commented 8 years ago

I understand that, but at first time when i run code, in log all OK, but mail dont send, and when i try run code at second time, first message back to the broker and in log error. Why email not send at first time? Python code to send in broker:

 channel.basic_publish(exchange='X',
              routing_key='ArtemLiubymov@yandex.ru',
              body=MESSAGE.as_string(),
              properties=pika.BasicProperties(
                 delivery_mode = 2, # make message persistent
         content_type = 'text/plain',
                 headers = {'subject':'Helloo',
                            'date':'7.1.2016'}
              ))    
artemliubymov commented 8 years ago

Сan anybody help me?

gotthardp commented 8 years ago

I'm sorry for the delay-- this is not my day job, so sometimes it takes me few days to setup the test environment and reproduce the problem. The error during the second run is caused by a (hidden) failure during the first run. I made a fix that will make the first error explicit. Would you be able to download the latest sources, build an updated plugin and re-test?

artemliubymov commented 8 years ago

Hi, I update plugin, run this python code:

 import smtplib
 from email.mime.multipart import MIMEMultipart
 from email.mime.text import MIMEText
 import pika

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

 me = 'test.ekadastr@yandex.ru'
 you = 'ArtemLiubymov@yandex.ru'

 MESSAGE = MIMEMultipart('alternative')
   MESSAGE['subject'] = 'Hello'
 msg_text = 'helllo woooooooooooorld'
   MESSAGE['To'] = you
   MESSAGE['From'] = me
   MESSAGE.preamble = """"""
   HTML_BODY = MIMEText(msg_text, 'plain', "utf-8")
   MESSAGE.attach(HTML_BODY)

 try:

s = smtplib.SMTP('localhost', 2525)

s.login("guest", "guest")

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

channel.basic_publish(exchange='X',
              routing_key='ArtemLiubymov@yandex.ru',
              body=MESSAGE.as_string(),
              properties=pika.BasicProperties(
                 delivery_mode = 2, # make message persistent
         content_type = 'text/plain',
                 headers = {'subject':'Helloo',
                            'date':'7.1.2016'}
              ))        

s.sendmail(me, you, MESSAGE.as_string())#msg.as_string())   
s.quit()

print('Success')
except: 
print('fail')
 connection.close()

But nothing change, When i run this code at first time in log all OK and email don't send, log for first run:

 =INFO REPORT==== 11-Jan-2016::21:14:14 ===
accepting AMQP connection <0.360.0> (127.0.0.1:59761 -> 127.0.0.1:5672)

 =INFO REPORT==== 11-Jan-2016::21:14:14 ===
example.com SMTP connection from {127,0,0,1}

 =INFO REPORT==== 11-Jan-2016::21:14:14 ===
 EHLO from [127.0.0.1]

 =INFO REPORT==== 11-Jan-2016::21:14:14 ===
 sending <<"text">>/<<"plain">> e-mail to <<"ArtemLiubymov@yandex.ru">>

  =INFO REPORT==== 11-Jan-2016::21:14:14 ===
   text/plain message from test.ekadastr@yandex.ru to [<<"ArtemLiubymov@yandex.ru">>] queued  
   as 0058ff19cc4c943f427f3b4c0708b242

   =INFO REPORT==== 11-Jan-2016::21:14:14 ===
    {'EXIT',<0.391.0>,normal}

    =INFO REPORT==== 11-Jan-2016::21:14:14 ===
      closing AMQP connection <0.360.0> (127.0.0.1:59761 -> 127.0.0.1:5672)

And when i run code at second time in log was ERROR:

    =ERROR REPORT==== 11-Jan-2016::21:14:44 ===
    ** Generic server <0.285.0> terminating
    ** Last message in was {consumer_call,
                       {'basic.deliver',<<"example.com">>,2,false,
                           <<"X">>,<<"ArtemLiubymov@yandex.ru">>},
                       {amqp_msg,
                           {'P_basic',<<"text/plain">>,undefined,
                               [{<<"date">>,longstr,<<"7.1.2016">>},
                                {<<"subject">>,longstr,<<"Helloo">>}],
                               2,undefined,undefined,undefined,undefined,
                               undefined,undefined,undefined,undefined,
                               undefined,undefined},
                           <<"Content-Type: multipart/alternative;  
     boundary=\"===============7843664812761565829==\"\nMIME-Version: 1.0\nsubject:  
     Hello\nTo: ArtemLiubymov@yandex.ru\nFrom: test.ekadastr@yandex.ru\n\n\n-- 
    ===============7843664812761565829==\nContent-Type: text/plain; charset=\"utf- 
    8\"\nMIME-Version: 1.0\nContent-Transfer-Encoding:  
     base64\n\naGVsbGxvIHdvb29vb29vb29vb29ybGQ=\n\n-- 
     ===============7843664812761565829==--\n">>}}
     ** When Server state == {state,amqp_selective_consumer,
                        {state,
                            {dict,0,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 [],[],[]},
                                {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                  [],[],[]}}},
                            undefined,
                            {dict,0,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 [],[],[]},
                                {{[],[],[],[],[],[],[],[],[],[],[],[],[],
                                  [],[],[]}}},
                            none}}
   ** Reason for termination == 
  ** unexpected_delivery_and_no_default_consumer

     =INFO REPORT==== 11-Jan-2016::21:14:44 ===
      text/plain message from test.ekadastr@yandex.ru to [<<"ArtemLiubymov@yandex.ru">>]  
      queued as 2f7fbf1cbf9ec39af9925270db4da9e9

Maybe i need edit config file?Or what?

artemliubymov commented 8 years ago

I look at issue 16, and can you say me, can i send email, using MIME headers?

gotthardp commented 8 years ago

What headers do you need? As described here, the AMQP message headers you send will get converted to the MIME headers. Just use the 'headers' parameter to set the headers when publishing a message. The 'content_type' has it's own parameter, but please note that multipart content-types are not tested and probably won't work.

artemliubymov commented 8 years ago

I all understand, it's work:) Thank you very much:) And one question can i change notify@ to another?

gotthardp commented 8 years ago

You mean the 'noreply@' in the From header? This can be set in the configuration file.

artemliubymov commented 8 years ago

If it {client_sender, "noreply@example.com"}, then its not work, 'noreply@' don't changed

gotthardp commented 8 years ago

Oops, yes. You're right. This is a hardcoded string. I cannot be changed at this moment.

artemliubymov commented 8 years ago

{email_headers, ["subject", "from", "charset"]} and it's not help?

artemliubymov commented 8 years ago

i try {email_headers,[{"from", 'xxx@xxx.com'}]} it's not help

DrMartiner commented 8 years ago

@ArtemLubimov Hi! Did you sent email via the plugin? I got your examples ( https://github.com/gotthardp/rabbitmq-email/issues/16 ) and try to sent simple email, but I couldn't get =(

gotthardp commented 8 years ago

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.

artemliubymov commented 8 years ago

for me AMQP to SMTP work, second no. Can you please change 'noreply@...' to client_sender value from configuration file?

gotthardp commented 8 years ago

I just made the 'noreply' configurable. See the README for configuration details, but please note that the client_sender is the MIME FROM, whereas the new email_from if the From header. These two information may be different (but can be the same as well). If you want to debug the SMTP to AMQP, please check the logs to see if there are any errors. I added few more logs.

artemliubymov commented 8 years ago

Sorry for late feedback. Yes i want to debug SMTP to AMQP. In logs no error. Log file:

=INFO REPORT==== 25-Jan-2016::12:04:51 ===
yandex.ru SMTP connection from {127,0,0,1}

=INFO REPORT==== 25-Jan-2016::12:04:51 ===
EHLO from [127.0.0.1]

=INFO REPORT==== 25-Jan-2016::12:04:51 ===
text/plain message from test.ekadastr@yandex.ru to [<<"ArtemLiubymov@yandex.ru">>] queued as  a87d91d5cc574b55827228b7a54f6901

=INFO REPORT==== 25-Jan-2016::12:04:51 === {'EXIT',<0.14094.0>,normal}

Code the same that in your example. What's wrong?

gotthardp commented 8 years ago

This may be linked to the issue https://github.com/gotthardp/rabbitmq-email/issues/20.

SDKiller commented 8 years ago

https://github.com/gotthardp/rabbitmq-email/issues/13#issuecomment-170978059

The 'content_type' has it's own parameter, but please note that multipart content-types are not tested and probably won't work.

Actually it works weird, I struggled for a while with creating multipart messages.

The problem was that if I set content_type property of AMPQ message to multipart/alternative - Content-Type email header appeared, but my boundary was replaced their with generated. That resulted incorrect email display.

Finally I came to solution to set AMPQ content_type property to text/plain and pass correct content type with correct boundary to headers array. This trick worked (at least for gmail and yandex) - html is displayed correctly.

lukebakken commented 3 years ago

Closing due to inactivity.