postal icon indicating copy to clipboard operation
postal copied to clipboard

Held messages

Open elfeffe opened this issue 9 years ago • 36 comments

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?

elfeffe avatar Jun 20 '17 10:06 elfeffe

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.

iammattmartin avatar Jun 20 '17 16:06 iammattmartin

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

elfeffe avatar Jun 20 '17 16:06 elfeffe

Yes, the problem is that we have more than 500 held messages :)

elfeffe avatar Jun 22 '17 14:06 elfeffe

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?

ravimantri avatar Jul 05 '17 22:07 ravimantri

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 avatar Jul 06 '17 09:07 adamcooke

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

adamcooke avatar Jul 06 '17 10:07 adamcooke

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

Looking for your help. Thanks

ravimantri avatar Jul 13 '17 12:07 ravimantri

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?

vady112 avatar Jul 19 '17 13:07 vady112

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

adamcooke avatar Jul 19 '17 14:07 adamcooke

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

vady1 avatar Jul 24 '17 10:07 vady1

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

ravimantri avatar Jul 27 '17 08:07 ravimantri

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

adamcooke avatar Jul 27 '17 08:07 adamcooke

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) }

ravimantri avatar Jul 27 '17 08:07 ravimantri

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.

adamcooke avatar Jul 27 '17 08:07 adamcooke

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

What to do?

ravimantri avatar Jul 27 '17 08:07 ravimantri

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) }

adamcooke avatar Jul 27 '17 09:07 adamcooke

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 avatar Jul 27 '17 09:07 ravimantri

@adamcooke, anymore suggestions? Thanks

ravimantri avatar Jul 27 '17 12:07 ravimantri

It worked for me, thanks!

chocochrispi avatar Oct 10 '17 11:10 chocochrispi

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

Thanks!

influenist avatar Jan 18 '18 23:01 influenist