Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Held messages #239

Closed
elfeffe opened this issue Jun 20, 2017 · 34 comments
Closed

Held messages #239

elfeffe opened this issue Jun 20, 2017 · 34 comments

Comments

@elfeffe
Copy link

elfeffe commented Jun 20, 2017

I think there is no sense to held messages for one month, the world can end in one month.
Is there any way to auto clean held messages?

@iammattmartin
Copy link

This is more user preference than a wide logic.

Some would argue it is better to have the message sent than not at all. We have broadband customers who decide to host their own mail server and due to fault/outage/power/whatever, their service could be broken and a repair could take time - I know for them, they'd not want to lose email.

@elfeffe
Copy link
Author

elfeffe commented Jun 20, 2017

I understand.
But at least any interface (or setting) to handle it will be great.
We can't delete held messages.

@elfeffe
Copy link
Author

elfeffe commented Jun 22, 2017 via email

@ravimantri
Copy link

Issue I've about 100K emails stuck with status "held". So the main thing is how can I delete all emails or force all to deliver?

@adamcooke
Copy link
Contributor

adamcooke commented Jul 6, 2017

If you have a lot of held outgoing messages, you can use the console to put them all back into your message queue and have them resend.

postal console
Server['org-name/server-name'].message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

@adamcooke
Copy link
Contributor

I've added two issues to assist with these issues. #257 and #256

@ravimantri
Copy link

@catphish @adamcooke, It' very urgent! How can I delete the held list (100K) all at once?

Looking for your help. Thanks

@vady112
Copy link

vady112 commented Jul 19, 2017

NoMethodError: undefined method `message_db' for nil:NilClass
	from (irb):1
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console.rb:65:in `start'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console_helper.rb:9:in `start'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:78:in `console'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'
irb(main):002:0> 

Getting this error what am I doing wrong?

@adamcooke
Copy link
Contributor

You've entered the server name and/or organization name incorrectly.

@vady1
Copy link

vady1 commented Jul 24, 2017

Thank you for reply. From where will I get server name?

@ravimantri
Copy link

ravimantri commented Jul 27, 2017

Dear @adamcooke by running "Server['org-name/server-name'].message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }". Ihad changed the Server Name.

I get "NoMethodError: undefined method `message_db' for nil:NilClass"

What to do? My all emails are stuck in held, nothing processing.

Thanks

@adamcooke
Copy link
Contributor

You've entered the server name and/or organization name incorrectly.

@ravimantri
Copy link

Thanks for your prompt reply. I actually used:

Server['gupta-publications/smtp-1'].message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

@adamcooke
Copy link
Contributor

You can get the correct org & server names from the URL in the web interface. I'd suggest that gupta-publications/smtp-1 is wrong.

@ravimantri
Copy link

ravimantri commented Jul 27, 2017

This is the Postal Interface I access: https://postal.domain.com/org/gupta-publications/servers/smtp-1

What to do?

@adamcooke
Copy link
Contributor

adamcooke commented Jul 27, 2017

You can try to get the server

server = Organization.find_by_permalink('org-name').servers.find_by_permalink('smtp-1')
server.message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { \|m\| m.add_to_message_queue(:manual => true) }

@ravimantri
Copy link

irb(main):004:0> server = Organization.find_by_permalink('gupta-publications').servers.find_by_permalink('smtp-1')
=> #<Server id: 1, organization_id: 1, uuid: "673f939a-b43b-4b7d-87a6-6a572cda6034", name: "SMTP - 1", mode: "Live", ip_pool_id: nil, created_at: "2017-07-26 14:35:51", updated_at: "2017-07-27 08:42:53", permalink: "smtp-1", send_limit: 100, deleted_at: nil, message_retention_days: 2, raw_message_retention_days: 1, raw_message_retention_size: 512, allow_sender: false, token: "uato7r", send_limit_approaching_at: nil, send_limit_approaching_notified_at: nil, send_limit_exceeded_at: nil, send_limit_exceeded_notified_at: nil, spam_threshold: #BigDecimal:7cb1310,'0.5E1',9(18), spam_failure_threshold: #BigDecimal:7cb11d0,'0.2E2',9(18), postmaster_address: nil, suspended_at: nil, outbound_spam_threshold: nil, domains_not_to_click_track: nil, suspension_reason: nil, log_smtp_data: false>

irb(main):005:0> server.message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }
SyntaxError: (irb):5: syntax error, unexpected $undefined
...:scope => 'outgoing'}).each { |m| m.add_to_message_queue(:...
... ^
from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console.rb:65:in start' from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console_helper.rb:9:in start'
from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:78:in console' from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in run_command!'
from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in <top (required)>' from bin/rails:4:in require'
from bin/rails:4:in `

'

@ravimantri
Copy link

@adamcooke, anymore suggestions? Thanks

@chocochrispi
Copy link

chocochrispi commented Oct 10, 2017

It worked for me, thanks!

@influenist
Copy link

Any option to delete the held queue by console? I see here only options to re-add them to the queue.

Thanks!

@PureMSP
Copy link

PureMSP commented Mar 28, 2018

Doesn't work for me neither.!

NoMethodError: undefined method `servers' for nil:NilClass
        from (irb):1
        from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console.rb:65:in `start'
        from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/console_helper.rb:9:in `start'
        from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:78:in `console'
        from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /opt/postal/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

No matter what I try!

@adamcooke
Copy link
Contributor

You're getting the organization name wrong if you're getting that error.

@hadifarnoud
Copy link

what if I want to cancel them all @adamcooke ? can you post the query for that too?

@Humblr
Copy link

Humblr commented Dec 16, 2018

Can we do the same for Hard Failed and bounced emails?
Got a few thousand that hard failed as our IP got blocked for a few days.

@njolin
Copy link

njolin commented Apr 16, 2019

@adamcooke can you shed some light on how to delete the held messages using the console please? Thanks!

@lovelyns
Copy link

If you have a lot of held outgoing messages, you can use the console to put them all back into your message queue and have them resend.

postal console
Server['org-name/server-name'].message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

Hello @adamcooke
please how do i get message_db ?

@lovelyns
Copy link

If you have a lot of held outgoing messages, you can use the console to put them all back into your message queue and have them resend.

postal console
Server['org-name/server-name'].message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

Hello @adamcooke
please how do i get message_db ?

I am getting the below error @adamcooke please help
NoMethodError: undefined method `message_db' for nil:NilClass

@willpower232
Copy link
Collaborator

This is answered above

You've entered the server name and/or organization name incorrectly.

@lovelyns
Copy link

Thanks @willpower232

Am I still on track?

I got the below result;

=> #<Server id: 1, organization_id: 1, uuid: "25d927cc-d369-413a-bd80-5468c20db4b1", name: "Mail Server 1", mode: "Live", ip_pool_id: nil, created_at: "2019-04-17 13:16:51", updated_at: "2019-05-10 13:49:45", permalink: "mail-server-1", send_limit: nil, deleted_at: nil, message_retention_days: 60, raw_message_retention_days: 30, raw_message_retention_size: 2048, allow_sender: true, token: "vchvvr", send_limit_approaching_at: nil, send_limit_approaching_notified_at: nil, send_limit_exceeded_at: nil, send_limit_exceeded_notified_at: nil, spam_threshold: #BigDecimal:6e4ea20,'0.5E1',9(18), spam_failure_threshold: #BigDecimal:6e4e908,'0.2E2',9(18), postmaster_address: nil, suspended_at: nil, outbound_spam_threshold: nil, domains_not_to_click_track: nil, suspension_reason: nil, log_smtp_data: true>
irb(main):002:0> server.message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

@lovelyns
Copy link

It worked for me, thanks!

Hi @chocochrispi
Could you please guide me on how you were able to get this done if my org name is matter and my server name is mail-server-10 ?

@chocochrispi
Copy link

chocochrispi commented May 23, 2019

It worked for me, thanks!

Hi @chocochrispi
Could you please guide me on how you were able to get this done if my org name is matter and my server name is mail-server-10 ?

server = Organization.find_by_permalink('matter').servers.find_by_permalink('mail-server-10')
server.message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

@lovelyns
Copy link

It worked for me, thanks!

Hi @chocochrispi
Could you please guide me on how you were able to get this done if my org name is matter and my server name is mail-server-10 ?

server = Organization.find_by_permalink('matter').servers.find_by_permalink('mail-server-10')
server.message_db.messages(:where => {:held => 1, :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

Thanks a million @chocochrispi it works

@udiffy
Copy link

udiffy commented May 19, 2023

Not work for version 2.1.4
How move all bounced messages to Queue from postal console?

@pjv
Copy link

pjv commented Mar 4, 2024

Here’s how to re-send all the hard fails:

postal console

Server['organization/server’].message_db.messages(:where => {:status => 'HardFail', :scope => 'outgoing'}).each { |m| m.add_to_message_queue(:manual => true) }

NOTE: you have to know what your organization and server are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests