-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
203 lines (191 loc) · 7.21 KB
/
index.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html>
<head>
<title>Email - iBacor</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- CSS font-awesome -->
<link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" />
<!-- CSS bootstrap -->
<link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<!-- CSS select2 -->
<link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" />
<!-- CSS DEMO -->
<style>
body {
background: #f5f5f5
}
.main {
background: #fff;
padding-bottom: 20px
}
.select2-container--default .select2-selection--multiple {
border: 1px solid #ccc
}
#message {
height: 200px
}
#result,
#log {
display: block;
margin-bottom: 20px;
background: #111;
color: #fff;
padding: 10px;
height: 400px;
overflow: auto
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 main">
<h1 align="center">New Message</h1>
<div class="form-group">
<label>To:</label>
<select class="form-control select2" name="to[]" multiple="">
<option value="[email protected]">[email protected]</option>
<option value="[email protected]">[email protected]</option>
<option value="[email protected]">[email protected]</option>
</select>
</div>
<div class="form-group">
<label>Cc:</label>
<select class="form-control select2" name="cc[]" multiple="">
<option value="[email protected]">[email protected]</option>
<option value="[email protected]">[email protected]</option>
<option value="[email protected]">[email protected]</option>
</select>
</div>
<div class="form-group">
<label>Bcc:</label>
<select class="form-control select2" name="bcc[]" multiple="">
<option value="[email protected]">[email protected]</option>
<option value="[email protected]">[email protected]</option>
<option value="[email protected]">[email protected]</option>
</select>
</div>
<div class="form-group">
<label>Subject:</label>
<input type="text" class="form-control" name="subject" placeholder="Hello">
</div>
<div class="form-group">
<label>Compose:</label>
<label class="radio-inline"><input type="radio" name="compose" value="html" checked>HTML</label>
<label class="radio-inline"><input type="radio" name="compose" value="text">Plain text</label>
<textarea class="form-control" name="message" id="message"></textarea>
</div>
<button type="submit" class="btn btn-primary" id="send"><i class="fa fa-paper-plane"></i> Send</button>
<a href="https://github.com/bachors/PHP-sending-emails-to-multiple-recipients" class="btn btn-warning" style="float: right"><i class="fa fa-code"></i> Source</a>
<hr>
<div class="col-md-6">
<label>Data:</label>
<textarea id="result" class="form-control"></textarea>
</div>
<div class="col-md-6">
<label>Log:</label>
<textarea id="log" class="form-control"></textarea>
</div>
</div>
</div>
<p align="center">iBacor.com</p>
</div>
<!-- jQuery -->
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<!-- select2 -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<!-- tinymce -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.2/tinymce.min.js"></script>
<script>
var data = new Object();
$( document ).ready(function() {
HTMLmessage();
$(".select2").select2({
tags: true,
placeholder: "[email protected], [email protected]"
});
$("#send").click(function(){
$("#log").val('');
var message = ($("input[name='compose']:checked").val() == 'html' ? tinyMCE.activeEditor.getContent() : $("#message").val())
if ($("[name='to[]']").val() != null && $("[name='subject']").val() != '' && message != '') {
data = {
'status': 'success',
'to': $("[name='to[]']").val(),
'cc': ($("[name='cc[]']").val() == null ? '' : $("[name='cc[]']").val().join()),
'bcc': ($("[name='bcc[]']").val() == null ? '' : $("[name='bcc[]']").val().join()),
'subject': $("[name='subject']").val(),
'type': $("input[name='compose']:checked").val(),
'compose': ($("input[name='compose']:checked").val() == 'html' ? '<html><body>' + message + '</body></html>' : message)
};
} else {
data = {
'status': 'error',
'message': 'Failed: Form input not empty.'
};
}
// Result: data
$("#result").val(JSON.stringify(data, null, 2));
// Send
sendRequest(data);
return false;
});
$("input[name='compose']").change(function() {
var c = $(this).val();
if(c == 'html'){
HTMLmessage();
}else {
tinymce.remove('#message');
}
return false;
});
});
function HTMLmessage() {
tinymce.init({
selector: '#message',
height: 200,
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc'
],
toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons | codesample',
image_advtab: true,
templates: [
{ title: 'Test template 1', content: 'Test 1' },
{ title: 'Test template 2', content: 'Test 2' }
],
content_css: [
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
'//www.tinymce.com/css/codepen.min.css'
]
});
}
// Looping request send email to server with ajax (client side)
function sendRequest(data) {
if(data.status == 'success'){
var ajaxRequest = new XMLHttpRequest(),
i = 0;
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readyState == 4) {
document.getElementById('log').value += ajaxRequest.responseText + '\n';
i++;
if(i < data.to.length) {
ajaxRequest.open("POST", "send.php", true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxRequest.send("to=" + data.to[i] + "&cc=" + data.cc + "&bcc=" + data.bcc + "&subject=" + data.subject + "&type=" + data.type + "&compose=" + data.compose);
}
}
};
ajaxRequest.open("POST", "send.php", true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxRequest.send("to=" + data.to[i] + "&cc=" + data.cc + "&bcc=" + data.bcc + "&subject=" + data.subject + "&type=" + data.type + "&compose=" + data.compose);
}
}
</script>
</body>
</html>