-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f788652
commit 5a77d45
Showing
4 changed files
with
35 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,47 @@ | ||
require 'mail' | ||
|
||
Mail.defaults do | ||
delivery_method :smtp, { | ||
address: ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.net', | ||
port: ENV['MAILOSAUR_SMTP_PORT'] || 25, | ||
enable_starttls_auto: false | ||
} | ||
delivery_method :smtp, { | ||
address: ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.net', | ||
port: ENV['MAILOSAUR_SMTP_PORT'] || 25 | ||
} | ||
end | ||
|
||
class Mailer | ||
@@html = File.open('test/resources/testEmail.html').read | ||
@@text = File.open('test/resources/testEmail.txt').read | ||
@@verified_domain = ENV['MAILOSAUR_VERIFIED_DOMAIN'] || 'mailosaur.net' | ||
|
||
def self.send_emails(client, server, quantity) | ||
(1..quantity).each do |_i| | ||
send_email(client, server) | ||
end | ||
@@html = File.open('test/resources/testEmail.html').read | ||
@@text = File.open('test/resources/testEmail.txt').read | ||
@@verified_domain = ENV['MAILOSAUR_VERIFIED_DOMAIN'] || 'mailosaur.net' | ||
|
||
def self.send_emails(client, server, quantity) | ||
(1..quantity).each do |_i| | ||
send_email(client, server) | ||
end | ||
end | ||
|
||
def self.send_email(client, server, send_to_address = nil) | ||
Mail.deliver do | ||
random_string = (0...10).map { rand(65..90).chr }.join | ||
def self.send_email(client, server, send_to_address = nil) | ||
Mail.deliver do | ||
random_string = (0...10).map { rand(65..90).chr }.join | ||
|
||
subject '%s subject' % [random_string] | ||
random_to_address = send_to_address || client.servers.generate_email_address(server) | ||
subject format('%s subject', random_string) | ||
random_to_address = send_to_address || client.servers.generate_email_address(server) | ||
|
||
from '%s %s <%s@%s>' % [random_string, random_string, random_string, @@verified_domain] | ||
to '%s %s <%s>' % [random_string, random_string, random_to_address] | ||
from format('%s %s <%s@%s>', random_string, random_string, random_string, @@verified_domain) | ||
to format('%s %s <%s>', random_string, random_string, random_to_address) | ||
|
||
text_part do | ||
body @@text.to_s.gsub('REPLACED_DURING_TEST', random_string) | ||
end | ||
text_part do | ||
body @@text.to_s.gsub('REPLACED_DURING_TEST', random_string) | ||
end | ||
|
||
html_part do | ||
content_type 'text/html; charset=UTF-8' | ||
body @@html.to_s.gsub('REPLACED_DURING_TEST', random_string) | ||
end | ||
html_part do | ||
content_type 'text/html; charset=UTF-8' | ||
body @@html.to_s.gsub('REPLACED_DURING_TEST', random_string) | ||
end | ||
|
||
add_file 'test/resources/cat.png' | ||
add_file 'test/resources/dog.png' | ||
add_file 'test/resources/cat.png' | ||
add_file 'test/resources/dog.png' | ||
|
||
inline = attachments['cat.png'] | ||
inline.content_id = 'ii_1435fadb31d523f6' | ||
end | ||
inline = attachments['cat.png'] | ||
inline.content_id = 'ii_1435fadb31d523f6' | ||
end | ||
end | ||
end |