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
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<label for = "to"> To: </label> | ||
<input name="to" type="text"/> | ||
|
||
<label for = "subject"> Subject: </label> | ||
<input name="subject" type="text"/> | ||
|
||
<label for = "body"> Body: </label> | ||
<textarea name="body"> | ||
</textarea> |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Compose | ||
module ActionHandler | ||
def button | ||
mail_from = settings.from | ||
mail_to = payload.overlay.to | ||
mail_subject = payload.overlay.subject | ||
mail_body = payload.overlay.body | ||
ssl = settings.ssl == '1' ? true : false | ||
|
||
return [500, 'Invalid From Address'] unless valid_email?(mail_from) | ||
return [500, 'Invalid To Address'] unless valid_email?(payload.overlay.to) | ||
|
||
mail = Mail.new do | ||
from mail_from | ||
to mail_to | ||
subject mail_subject | ||
body mail_body | ||
end | ||
|
||
mail.delivery_method(:smtp, { | ||
address: settings.server, | ||
port: settings.server_port.to_i, | ||
user_name: settings.username, | ||
password: settings.password, | ||
authentication: 'plain', | ||
enable_starttls_auto: true, | ||
ssl: ssl | ||
}) | ||
|
||
begin | ||
mail.deliver | ||
rescue Exception => e | ||
return [500, e.message] | ||
end | ||
|
||
[200, "Message sent to #{mail_to}"] | ||
end | ||
end | ||
end | ||
|
||
module Compose | ||
class Base < SupportBeeApp::Base | ||
string :server, :required => true, :label => "SMTP Server Address" | ||
string :server_port, :required => true, :label => "SMTP Server Port" | ||
string :username, :required => true, :label => "Username" | ||
password :password, :required => true, :label => "Password" | ||
string :from, :required => true, :label => "From Address" | ||
boolean :ssl, :default => true, :label => "SSL" | ||
|
||
white_list :server, :server_port, :ssl | ||
|
||
private | ||
|
||
def valid_email?(email) | ||
true | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Compose | ||
slug: compose | ||
access: public | ||
|
||
description: " | ||
Initiate conversations with your customer right from inside SupportBee. | ||
" | ||
|
||
category: Feature | ||
|
||
tags: | ||
- compose | ||
|
||
developer: | ||
name: Avinasha S | ||
email: me@avinasha.com | ||
twitter: "@avishastry" | ||
github: avinasha | ||
|
||
action: | ||
button: | ||
overlay: true | ||
screens: | ||
- ticket | ||
label: Compose |