9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/ses_dashboard/test_emails_controller.rb', line 9
def create
from = params[:from].presence || SesDashboard.configuration.test_email_from
to = params[:to].presence
subject = params[:subject].presence || "Test email from SES Dashboard"
body = params[:body].presence || "This is a test email sent via the SES Dashboard."
unless from && to
flash.now[:alert] = "From and To addresses are required."
@from = from
return render :new, status: :unprocessable_entity
end
begin
ses_client = SesDashboard::Client.new
ses_client.send_email(from: from, to: to, subject: subject, body: body)
redirect_to project_path(@project), notice: "Test email sent to #{to}."
rescue => e
flash.now[:alert] = "Failed to send email: #{e.message}"
@from = from
render :new, status: :unprocessable_entity
end
end
|