gotthardp/rabbitmq-email

error on sending email

samjadmooppan opened this issue · 10 comments

Hi,

I am finding it difficut to get the rabbitmq-email and postfix to get working.

getting the following error while sending email

sam@domain.com: mail for domain.com loops back to
myself

Can you please post

  • More details about what exactly you are trying to do
  • RabbitMQ server logs contents
  • The entire stack trace (if it is not in the logs)

Thanks Michael,

  1. I am working on an application which will push an email to RabbitMQ using Postfix and rabbitmq-email. The data will then be fetched from rabbitMQ queue and pushed to a database.
  2. There is nothing on the rabbitmq logs. My configuration for rabbitmq-email is as follows

{rabbitmq_email, [
{server_config, [
[{port, 25}, {protocol, tcp}, {domain, "app.mydomain.com"}, {address,{0,0,0,0}}]
]},
{server_auth, rabbitmq},
{server_starttls, true},
{email_domains,
[{<<"app.mydomain.com">>, {<<"/">>, <<"email-in">>}}
]},
{email_queues,
[{{<<"/">>, <<"email-out">>}, <<"app.mydomain.com">>}
]},
{client_sender, "arun@app.mydomain.com"},
{client_config, [
{relay, "app.mydomain.com"}
]}
]}

  1. The postfix configuration main.cf is as follows

> 
> # See /usr/share/postfix/main.cf.dist for a commented, more complete version
> 
> 
> # Debian specific:  Specifying a file name will cause the first
> # line of that file to be used as the name.  The Debian default
> # is /etc/mailname.
> #myorigin = /etc/mailname
> 
> smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
> biff = no
> disable_dns_lookups = yes
> # appending .domain is the MUA's job.
> append_dot_mydomain = no
> 
> # Uncomment the next line to generate "delayed mail" warnings
> #delay_warning_time = 4h
> 
> readme_directory = no
> 
> # TLS parameters
> smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
> smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
> smtpd_use_tls=yes
> smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
> smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
> 
> # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
> # information on enabling SSL in the smtp client.
> 
> #smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
> myhostname = app.mydomain.com
> alias_maps = hash:/etc/aliases
> alias_database = hash:/etc/aliases
> myorigin = /etc/mailname
> mydestination = localhost.$mydomain, localhost, $myhostname
> relayhost =
> mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
> mailbox_command = procmail -a "$EXTENSION"
> mailbox_size_limit = 0
> recipient_delimiter = +
> inet_interfaces = all
> inet_protocols = all
> relay_domains = $mydestination, gmail.com, app.mydomain.com, activelobby.net, server.supportlobby.com
> transport_maps = hash:/etc/postfix/transport


  1. The postfix transport file is

app.mydomain.com smtp:app.mydomain.com:25

  1. When i try to send a mail to arun@app.mydomain.com , the postfix logs shows the following

Jun 19 14:28:56 zimbra postfix/smtpd[2453]: connect from server.supportlobby.com[158.69.11.64]
Jun 19 14:28:56 zimbra postfix/smtpd[2453]: 1E549C1BEB: client=server.supportlobby.com[158.69.11.64]
Jun 19 14:28:56 zimbra postfix/cleanup[2458]: 1E549C1BEB: message-id=c42fe5b1-ab74-fcec-82a5-3598d7b5ffb1@activelobby.net
Jun 19 14:28:56 zimbra postfix/qmgr[2445]: 1E549C1BEB: from=sam@activelobby.net, size=2178, nrcpt=1 (queue active)
Jun 19 14:28:56 zimbra postfix/smtp[2459]: 1E549C1BEB: to=arun@app.mydomain.com, relay=none, delay=0.03, delays=0.03/0/0/0, dsn=5.4.6, status=bounced (mail for app.mydomain.com loops back to myself)
Jun 19 14:28:56 zimbra postfix/cleanup[2458]: 3344FC1BEC: message-id=20160619142856.3344FC1BEC@app.mydomain.com
Jun 19 14:28:56 zimbra postfix/smtpd[2453]: disconnect from server.supportlobby.com[xx.xx.xx.xx]
Jun 19 14:28:56 zimbra postfix/bounce[2460]: 1E549C1BEB: sender non-delivery notification: 3344FC1BEC
Jun 19 14:28:56 zimbra postfix/qmgr[2445]: 3344FC1BEC: from=<>, size=4084, nrcpt=1 (queue active)
Jun 19 14:28:56 zimbra postfix/qmgr[2445]: 1E549C1BEB: removed
Jun 19 14:28:56 zimbra postfix/smtp[2463]: 3344FC1BEC: to=sam@activelobby.net, relay=activelobby.net[xx.xx.xx.xx]:25, delay=0.41, delays=0.04/0.01/0.14/0.21, dsn=2.0.0, status=sent (250 OK id=1bEdie-0006yd-FO)
Jun 19 14:28:56 zimbra postfix/qmgr[2445]: 3344FC1BEC: removed

  1. The bounce message is
    The mail system

arun@app.mydomain.com: mail for app.mydomain.com loops back to
myself

It think the postfix is misconfigured. By doing this

myhostname = app.mydomain.com
mydestination = localhost.$mydomain, localhost, $myhostname
relay_domains = $mydestination, gmail.com, app.mydomain.com, activelobby.net, server.supportlobby.com

you essentially say that mail for app.mydomain.com should be delivered to the postfix server and at the same time that it shall be relayed to another server, whose address points again to the same postfix server (itself), which is the error you are getting.

Please add the domain that corresponds to the rabbitmq-email instance only to the relay_domains.

Thanks Guys,

Got it working. I have one more clarification. I am looking to pool multiple mail domains . For eg : app1.mydomain.com, app2.mydomain.com ....app'n'.mydomian.com to rabbitmq email.

The rabbitmq shows that the messages are queued , however its not there in the configured queue.

`
=INFO REPORT==== 23-Jun-2016::05:06:31 ===
text/plain message from sam@activelobby.net to [<<"arun@app2.mydomain.com">>] queued as 75525d3b83b21b1bc8f4390471199dae

=INFO REPORT==== 23-Jun-2016::05:06:31 ===
{'EXIT',<0.867.0>,normal}

=INFO REPORT==== 23-Jun-2016::05:06:31 ===
text/plain message from sam@activelobby.net to [<<"arun@app.mydomain.com">>] queued as 9b0994f6a3628a0ac6c273951c77a1e1

=INFO REPORT==== 23-Jun-2016::05:06:31 ===
{'EXIT',<0.889.0>,normal}

`

Please note that incoming e-mails are sent to the AMQP Exchange you configured in email_domains. If this exchange is not bound to any queue, the AMQP message gets discarded. Couldn't this be the case?

I had the exchange type set as topic. Worked once i configured the queue correctly . Thanks again :) . All issues solved :)

Hi gotthardp

Thank you for great help. Now how do i get rabbitMQ to send back mail to my postfix server sitting somewhere, it seems sending to rabbitMQ looks great. How do you route back mail to postfix server.

Hello. The outgoing mail is sent to a SMTP server, which then delivers it to Postfix or any other target recipient.

Thank you, so if i have more than one domain i want rabbitMQ to handle i should define them on the rabbitMQ server under RabbitMQ Configuration as this server wont accept mail for unknown recipients ?

i have more than one domain for my Apps , i have sub-domains as well i want rabbitMQ to handle mail for