35 lines
845 B
Dart
35 lines
845 B
Dart
|
// Copyright (c) 2016, Marcel Kapfer (mmk2410).
|
||
|
// MIT License
|
||
|
|
||
|
import 'dart:convert';
|
||
|
import 'dart:html';
|
||
|
|
||
|
void main() {
|
||
|
// send mail listener
|
||
|
querySelector("#send").onClick.listen(sendMail);
|
||
|
}
|
||
|
|
||
|
void sendMail(MouseEvent event) {
|
||
|
InputElement title = querySelector("#mailtitle");
|
||
|
InputElement text = querySelector("#mailtext");
|
||
|
InputElement filename = querySelector("#filename");
|
||
|
InputElement addresslist = querySelector("#address_list");
|
||
|
|
||
|
Map data = {
|
||
|
"title": title.value,
|
||
|
"body": text.value,
|
||
|
"filename": filename.value,
|
||
|
"list": addresslist.value
|
||
|
};
|
||
|
|
||
|
String url = "/res/php/sendmail.php?data=${JSON.encode(data)}";
|
||
|
|
||
|
HttpRequest.getString(url).then((response) {
|
||
|
if (response == "0") {
|
||
|
window.alert("Mails successfully sent.");
|
||
|
} else {
|
||
|
window.alert("Failed to send mail.");
|
||
|
}
|
||
|
});
|
||
|
}
|