-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmail-lib.rb
36 lines (30 loc) · 839 Bytes
/
mail-lib.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# encoding: UTF-8
require 'mail'
require 'yaml'
# helper function for emailing stuff to Kindle, etc
def mail_file(file)
curpath = File.dirname(File.expand_path(__FILE__)) + "/"
# get passwords and email
conf = YAML::load(File.read(curpath + "config.yaml"))
# we're using GMail
options = { :address => "smtp.gmail.com",
:port => 587,
:domain => 'localhost',
:user_name => conf["email"],
:password => conf["password"],
:authentication => 'plain',
:enable_starttls_auto => true
}
Mail.defaults do
delivery_method :smtp, options
end
@mail = Mail.deliver do
to conf["receiver"]
from conf["email"]
subject 'convert'
text_part do
body 'sent from bibdesk'
end
add_file file
end
end