Skip to content

Commit 21e3dea

Browse files
committed
Init
0 parents  commit 21e3dea

File tree

9 files changed

+303
-0
lines changed

9 files changed

+303
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.cr]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true

.gitignore

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/docs/
2+
/lib/
3+
/bin/
4+
/.shards/
5+
*.dwarf
6+
7+
.vscode/*
8+
!.vscode/settings.json
9+
!.vscode/tasks.json
10+
!.vscode/launch.json
11+
!.vscode/extensions.json
12+
!.vscode/*.code-snippets
13+
14+
# Local History for Visual Studio Code
15+
.history/
16+
17+
# Built Visual Studio Code Extensions
18+
*.vsix
19+
20+
# General
21+
.DS_Store
22+
.AppleDouble
23+
.LSOverride
24+
25+
# Icon must end with two \r
26+
Icon
27+
28+
29+
# Thumbnails
30+
._*
31+
32+
# Files that might appear in the root of a volume
33+
.DocumentRevisions-V100
34+
.fseventsd
35+
.Spotlight-V100
36+
.TemporaryItems
37+
.Trashes
38+
.VolumeIcon.icns
39+
.com.apple.timemachine.donotpresent
40+
41+
# Directories potentially created on remote AFP share
42+
.AppleDB
43+
.AppleDesktop
44+
Network Trash Folder
45+
Temporary Items
46+
.apdisk
47+
48+
*.gem
49+
*.rbc
50+
/.config
51+
/coverage/
52+
/InstalledFiles
53+
/pkg/
54+
/spec/reports/
55+
/spec/examples.txt
56+
/test/tmp/
57+
/test/version_tmp/
58+
/tmp/
59+
60+
# Used by dotenv library to load environment variables.
61+
# .env
62+
63+
# Ignore Byebug command history file.
64+
.byebug_history
65+
66+
## Specific to RubyMotion:
67+
.dat*
68+
.repl_history
69+
build/
70+
*.bridgesupport
71+
build-iPhoneOS/
72+
build-iPhoneSimulator/
73+
74+
## Specific to RubyMotion (use of CocoaPods):
75+
#
76+
# We recommend against adding the Pods directory to your .gitignore. However
77+
# you should judge for yourself, the pros and cons are mentioned at:
78+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
79+
#
80+
# vendor/Pods/
81+
82+
## Documentation cache and generated files:
83+
/.yardoc/
84+
/_yardoc/
85+
/doc/
86+
/rdoc/
87+
88+
## Environment normalization:
89+
/.bundle/
90+
/vendor/bundle
91+
/lib/bundler/man/
92+
93+
# for a library or gem, you might want to ignore these files since the code is
94+
# intended to run in multiple environments; otherwise, check them in:
95+
# Gemfile.lock
96+
# .ruby-version
97+
# .ruby-gemset
98+
99+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
100+
.rvmrc
101+
102+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
103+
# .rubocop-https?--*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Martin Mareš <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# send-email
2+
3+
TODO: Write a description here
4+
5+
## Installation
6+
7+
TODO: Write installation instructions here
8+
9+
## Usage
10+
11+
TODO: Write usage instructions here
12+
13+
## Development
14+
15+
sentry -b "crystal build ./src/send-email.cr -o ./bin/send-email" \
16+
-r "./bin/send-email" \
17+
--run-args "-c conf/dev.yml"
18+
19+
## Contributing
20+
21+
1. Fork it (<https://github.com/your-github-user/send-email/fork>)
22+
2. Create your feature branch (`git checkout -b my-new-feature`)
23+
3. Commit your changes (`git commit -am 'Add some feature'`)
24+
4. Push to the branch (`git push origin my-new-feature`)
25+
5. Create a new Pull Request
26+
27+
## Contributors
28+
29+
- [Martin Mareš](https://github.com/your-github-user) - creator and maintainer

shard.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2.0
2+
shards:
3+
email:
4+
git: https://github.com/arcage/crystal-email.git
5+
version: 0.6.3
6+

shard.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: send-email
2+
version: 0.1.0
3+
4+
authors:
5+
- Martin Mareš <[email protected]>
6+
7+
targets:
8+
send-email:
9+
main: src/send-email.cr
10+
11+
dependencies:
12+
email:
13+
github: arcage/crystal-email
14+
15+
crystal: 1.3.2
16+
17+
license: MIT

spec/send-email_spec.cr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "./spec_helper"
2+
3+
describe Send::Email do
4+
# TODO: Write tests
5+
6+
it "works" do
7+
false.should eq(true)
8+
end
9+
end

spec/spec_helper.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "spec"
2+
require "../src/send-email"

src/send-email.cr

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
require "email"
2+
require "option_parser"
3+
4+
module SendEmail
5+
VERSION = "0.1.0"
6+
7+
class App
8+
getter :hostname, :port
9+
10+
@hostname : String
11+
@port : Int32
12+
@debug : Bool
13+
14+
@subject : String
15+
@text : String
16+
@html : String
17+
18+
@from : String
19+
@recipients : Array(String)
20+
21+
def run()
22+
# Create email message
23+
email = EMail::Message.new
24+
email.from "[email protected]", "Notify"
25+
email.to "[email protected]"
26+
email.subject "Test email - hello world!"
27+
email.message <<-EOM
28+
Testovací email.
29+
30+
--
31+
Martin M.
32+
EOM
33+
34+
# Email HTML email body
35+
email.message_html <<-EOM
36+
37+
EOM
38+
39+
# Set SMTP client configuration
40+
# config = EMail::Client::Config.new("smtp.datalite.cz", 587)
41+
# config.use_tls(EMail::Client::TLSMode::STARTTLS)
42+
# config.tls_context.verify_mode = OpenSSL::SSL::VerifyMode::NONE
43+
config = EMail::Client::Config.new("oracleas.datalite.cz", 2525)
44+
45+
# Create SMTP client object
46+
client = EMail::Client.new(config)
47+
48+
client.start do
49+
# In this block, default receiver is client
50+
send(email)
51+
end
52+
end
53+
54+
def initialize()
55+
@hostname = ""
56+
@port = -1
57+
@debug = false
58+
59+
@subject = ""
60+
@text = ""
61+
@html = ""
62+
63+
@from = ""
64+
@recipients = [] of String
65+
66+
_opts = parse_opts()
67+
end
68+
69+
def parse_opts
70+
OptionParser.parse do |parser|
71+
parser.banner = "Usage: send-email [arguments]"
72+
73+
parser.on("-h HOSTNAME", "--hostname=HOSTNAME", "Hostname (SMTP)") { |_hostname| @hostname = _hostname }
74+
parser.on("-p PORT", "--port=PORT", "Port") { |_port| @port = _port.to_i }
75+
parser.on("-s SUBJECT", "--subject=SUBJECT", "Subject") { |_subject| @subject = _subject }
76+
parser.on("-f FROM", "--from=FROM", "From:") { |_from| @from = _from }
77+
parser.on("-r RECIPIENTS", "--recipients=RECIPIENTS", "RcptTo: (comma separated list)") do |_recipients|
78+
@recipients = _recipients.split(',')
79+
end
80+
parser.on("-t TXT", "--txt-body-file=TXT", "Text body file") { |_text| @text = _text }
81+
parser.on("-m HTML", "--html-body-file=HTML", "Html body file") { |_html| @html = _html }
82+
83+
parser.on("-d", "--debug", "Debug?") { @debug = true }
84+
parser.on("-v", "--version", "App version") do
85+
puts "App name: send-email"
86+
puts "App version: #{VERSION}"
87+
exit
88+
end
89+
parser.on("-h", "--help", "Show this help") do
90+
puts parser
91+
exit
92+
end
93+
parser.invalid_option do |flag|
94+
STDERR.puts "ERROR: #{flag} is not a valid option."
95+
STDERR.puts parser
96+
exit(1)
97+
end
98+
99+
end
100+
end
101+
102+
end
103+
104+
app = App.new
105+
app.run
106+
107+
end

0 commit comments

Comments
 (0)