Send Mail without a file attachment
This commit is contained in:
parent
bc9f84a64c
commit
cef1650686
4 changed files with 21 additions and 3 deletions
|
@ -68,6 +68,7 @@
|
||||||
<p>Change the text of the email if you want.</p>
|
<p>Change the text of the email if you want.</p>
|
||||||
<p>Title:</p><input id="mailtitle" name="title" class="itextfield" />
|
<p>Title:</p><input id="mailtitle" name="title" class="itextfield" />
|
||||||
<p>Text:</p><textarea id="mailtext" name="text" class="itextarea"></textarea>
|
<p>Text:</p><textarea id="mailtext" name="text" class="itextarea"></textarea>
|
||||||
|
<p><input type="checkbox" class="icheckbox" id="nofile" />Send without file</p>
|
||||||
<p>Filename:</p><input id="filename" name="filename" class="itextfield" />
|
<p>Filename:</p><input id="filename" name="filename" class="itextfield" />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,12 @@ input.button
|
||||||
.itextarea:focus
|
.itextarea:focus
|
||||||
@extend .itextfield
|
@extend .itextfield
|
||||||
|
|
||||||
|
.icheckbox
|
||||||
|
margin: 0
|
||||||
|
padding: 0
|
||||||
|
margin-right: 10px
|
||||||
|
vertical-align: sub
|
||||||
|
|
||||||
/* FILESPREAD */
|
/* FILESPREAD */
|
||||||
|
|
||||||
.edit_template
|
.edit_template
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2016, Marcel Kapfer (mmk2410).
|
// Copyright (c) 2016 - 2017, Marcel Kapfer (mmk2410).
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
@ -14,12 +14,14 @@ void sendMail(MouseEvent event) {
|
||||||
InputElement text = querySelector("#mailtext");
|
InputElement text = querySelector("#mailtext");
|
||||||
InputElement filename = querySelector("#filename");
|
InputElement filename = querySelector("#filename");
|
||||||
InputElement addresslist = querySelector("#address_list");
|
InputElement addresslist = querySelector("#address_list");
|
||||||
|
CheckboxInputElement nofile = querySelector("#nofile");
|
||||||
|
|
||||||
Map data = {
|
Map data = {
|
||||||
"title": title.value,
|
"title": title.value,
|
||||||
"body": text.value,
|
"body": text.value,
|
||||||
"filename": filename.value,
|
"filename": filename.value,
|
||||||
"list": addresslist.value
|
"list": addresslist.value,
|
||||||
|
"nofile": nofile.checked
|
||||||
};
|
};
|
||||||
|
|
||||||
String url = "res/php/sendmail.php?data=${JSON.encode(data)}";
|
String url = "res/php/sendmail.php?data=${JSON.encode(data)}";
|
||||||
|
@ -31,4 +33,5 @@ void sendMail(MouseEvent event) {
|
||||||
window.alert("Failed to send mail.");
|
window.alert("Failed to send mail.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,12 @@ function main($ini) {
|
||||||
|
|
||||||
$filename = $data["filename"];
|
$filename = $data["filename"];
|
||||||
|
|
||||||
|
$nofile = $data["nofile"];
|
||||||
|
|
||||||
|
if ($nofile) {
|
||||||
|
$filename = "";
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($addresses as $address) {
|
foreach ($addresses as $address) {
|
||||||
if (sendMail($title, $content, $filename, $address, $ini) != 0) {
|
if (sendMail($title, $content, $filename, $address, $ini) != 0) {
|
||||||
print "-1";
|
print "-1";
|
||||||
|
@ -46,7 +52,9 @@ function sendMail($title, $content, $filename, $address, $ini) {
|
||||||
$mail->addReplyTo($ini["reply"]);
|
$mail->addReplyTo($ini["reply"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($filename)) {
|
||||||
$mail->AddAttachment("../../assets/file.bin", $filename);
|
$mail->AddAttachment("../../assets/file.bin", $filename);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$mail->Send()) {
|
if (!$mail->Send()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Reference in a new issue