From ac90ab7c69b35546135cacf9ed2ed98261047dac Mon Sep 17 00:00:00 2001 From: pdp8 Date: Wed, 16 Aug 2023 15:25:17 +0200 Subject: mail and social --- mail.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 mail.rb (limited to 'mail.rb') diff --git a/mail.rb b/mail.rb new file mode 100755 index 0000000..dc983c2 --- /dev/null +++ b/mail.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +mailfile = if ARGV[1] and ARGV[1] == 'publish' + File.join(__dir__, 'mail', 'emails') + else + File.join(__dir__, 'mail', 'testmail') + end + +Dir.chdir ARGV[0] +date, title = File.basename(ARGV[0]).split('_', 2) +content = ["From: info@pdp8.info +Subject: [pdp8] #{title.gsub('_', ' ')} +Content-Type: text/plain +List-Unsubscribe: "] +content << '' +content << File.read('README') +content << '' +content << "https://pdp8.info/music.html\##{date}" +bc = if File.exist?('bandcamp') + File.read('bandcamp').chomp + else + "https://pdp8.bandcamp.com/album/#{title.gsub(' ', '-')}" + end +content << bc +content << '' +content << '==' +content << 'List-Unsubscribe: ' +File.open('/tmp/mail.txt', 'w+') { |f| f.puts content.join("\n") } +# system 'hx /tmp/mail.txt' +content = File.read('/tmp/mail.txt') + +File.open(mailfile).each_line do |mail| + mail.chomp! + txt = "To: #{mail}\n" + content + cmd = "echo -e \"#{txt}\" | sendmail #{mail}" + # puts cmd + puts mail + `#{cmd}` +end -- cgit v1.2.3