Issues (63)

email.php (4 issues)

1
<?php
2
3
// Import PHPMailer classes into the global namespace
4
// These must be at the top of your script, not inside a function
5
use PHPMailer\PHPMailer\PHPMailer;
0 ignored issues
show
The type PHPMailer\PHPMailer\PHPMailer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use PHPMailer\PHPMailer\Exception;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Exception. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
The type PHPMailer\PHPMailer\Exception was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
//Load Composer's autoloader
9
require 'vendor/autoload.php';
10
if (isset($_POST['emailId']) && isset($_POST['albumLocation'])) {
11
    $user_email = $_POST['emailId'];
12
    $user_album = $_POST['albumLocation'];
13
    $user_name = $_POST['name'];
14
    $mail_body = '<!doctype html>
15
        <html>
16
        <head>
17
            <meta name="viewport" content="width=device-width" />
18
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
19
            <title>Social Manager : Album Downloader</title>
20
            <style>
21
            /* -------------------------------------
22
                GLOBAL RESETS
23
            ------------------------------------- */
24
            img {
25
                border: none;
26
                max-width: 100%; }
27
28
            body {
29
                background-color: #f6f6f6;
30
                font-family: sans-serif;
31
                font-size: 14px;
32
                line-height: 1.4;
33
                margin: 0;
34
                padding: 0;
35
                -webkit-text-size-adjust: 100%; }
36
37
            table {
38
                border-collapse: separate;
39
                width: 100%; }
40
41
                table td {
42
                font-family: sans-serif;
43
                font-size: 14px;
44
                vertical-align: top; }
45
46
            /* -------------------------------------
47
                BODY & CONTAINER
48
            ------------------------------------- */
49
50
            .body {
51
                background-color: #f6f6f6;
52
                width: 100%; }
53
54
            /* Set a max-width, and make it display as block so it will automatically stretch to that width, but will also shrink down on a phone or something */
55
            .container {
56
                display: block;
57
                Margin: 0 auto !important;
58
                /* makes it centered */
59
                max-width: 580px;
60
                padding: 10px;
61
                width: 580px; }
62
63
            /* This should also be a block element, so that it will fill 100% of the .container */
64
            .content {
65
                box-sizing: border-box;
66
                display: block;
67
                Margin: 0 auto;
68
                max-width: 580px;
69
                padding: 10px; }
70
71
            /* -------------------------------------
72
                HEADER, FOOTER, MAIN
73
            ------------------------------------- */
74
            .main {
75
                background: #ffffff;
76
                border-radius: 3px;
77
                width: 100%; }
78
79
            .wrapper {
80
                box-sizing: border-box;
81
                padding: 20px; }
82
83
            .content-block {
84
                padding-bottom: 10px;
85
                padding-top: 10px;
86
            }
87
88
            .footer {
89
                clear: both;
90
                Margin-top: 10px;
91
                text-align: center;
92
                width: 100%; }
93
                .footer td,
94
                .footer p,
95
                .footer span,
96
                .footer a {
97
                color: #999999;
98
                font-size: 12px;
99
                text-align: center; }
100
101
            /* -------------------------------------
102
                TYPOGRAPHY
103
            ------------------------------------- */
104
            h1,
105
            h2,
106
            h3,
107
            h4 {
108
                color: #000000;
109
                font-family: sans-serif;
110
                font-weight: 400;
111
                line-height: 1.4;
112
                margin: 0;
113
                Margin-bottom: 30px; }
114
115
            h1 {
116
                font-size: 35px;
117
                font-weight: 300;
118
                text-align: center;
119
                text-transform: capitalize; }
120
121
            p,
122
            ul,
123
            ol {
124
                font-family: sans-serif;
125
                font-size: 14px;
126
                font-weight: normal;
127
                margin: 0;
128
                Margin-bottom: 15px; }
129
                p li,
130
                ul li,
131
                ol li {
132
                list-style-position: inside;
133
                margin-left: 5px; }
134
            .text-color-msg {
135
                color: #e53935;
136
            }
137
            a {
138
                color: #3498db;
139
                text-decoration: underline; }
140
141
            /* -------------------------------------
142
                BUTTONS
143
            ------------------------------------- */
144
            .btn {
145
                box-sizing: border-box;
146
                width: 100%; }
147
                .btn > tbody > tr > td {
148
                padding-bottom: 15px; }
149
                .btn table {
150
                width: auto; }
151
                .btn table td {
152
                background-color: #ffffff;
153
                border-radius: 5px;
154
                text-align: center; }
155
                .btn a {
156
                background-color: #ffffff;
157
                border: solid 1px #3498db;
158
                border-radius: 5px;
159
                box-sizing: border-box;
160
                color: #3498db;
161
                cursor: pointer;
162
                display: inline-block;
163
                font-size: 14px;
164
                font-weight: bold;
165
                margin: 0;
166
                padding: 12px 25px;
167
                text-decoration: none;
168
                text-transform: capitalize; }
169
170
            .btn-primary table td {
171
                background-color: #3498db; }
172
173
            .btn-primary a {
174
                background-color: #3498db;
175
                border-color: #3498db;
176
                color: #ffffff; }
177
178
            /* -------------------------------------
179
                OTHER STYLES THAT MIGHT BE USEFUL
180
            ------------------------------------- */
181
            .last {
182
                margin-bottom: 0; }
183
184
            .first {
185
                margin-top: 0; }
186
187
            .align-center {
188
                text-align: center; }
189
190
            .align-right {
191
                text-align: right; }
192
193
            .align-left {
194
                text-align: left; }
195
196
            .clear {
197
                clear: both; }
198
199
            .mt0 {
200
                margin-top: 0; }
201
202
            .mb0 {
203
                margin-bottom: 0; }
204
205
            .preheader {
206
                color: transparent;
207
                display: none;
208
                height: 0;
209
                max-height: 0;
210
                max-width: 0;
211
                opacity: 0;
212
                overflow: hidden;
213
                mso-hide: all;
214
                visibility: hidden;
215
                width: 0; }
216
217
            .powered-by a {
218
                text-decoration: none; }
219
220
            hr {
221
                border: 0;
222
                border-bottom: 1px solid #f6f6f6;
223
                Margin: 20px 0; }
224
225
            /* -------------------------------------
226
                RESPONSIVE AND MOBILE FRIENDLY STYLES
227
            ------------------------------------- */
228
            @media only screen and (max-width: 620px) {
229
                table[class=body] h1 {
230
                font-size: 28px !important;
231
                margin-bottom: 10px !important; }
232
                table[class=body] p,
233
                table[class=body] ul,
234
                table[class=body] ol,
235
                table[class=body] td,
236
                table[class=body] span,
237
                table[class=body] a {
238
                font-size: 16px !important; }
239
                table[class=body] .wrapper,
240
                table[class=body] .article {
241
                padding: 10px !important; }
242
                table[class=body] .content {
243
                padding: 0 !important; }
244
                table[class=body] .container {
245
                padding: 0 !important;
246
                width: 100% !important; }
247
                table[class=body] .main {
248
                border-left-width: 0 !important;
249
                border-radius: 0 !important;
250
                border-right-width: 0 !important; }
251
                table[class=body] .btn table {
252
                width: 100% !important; }
253
                table[class=body] .btn a {
254
                width: 100% !important; }
255
                table[class=body] .img-responsive {
256
                height: auto !important;
257
                max-width: 100% !important;
258
                width: auto !important; }}
259
260
            /* -------------------------------------
261
                PRESERVE THESE STYLES IN THE HEAD
262
            ------------------------------------- */
263
            @media all {
264
                .ExternalClass {
265
                width: 100%; }
266
                .ExternalClass,
267
                .ExternalClass p,
268
                .ExternalClass span,
269
                .ExternalClass font,
270
                .ExternalClass td,
271
                .ExternalClass div {
272
                line-height: 100%; }
273
                .apple-link a {
274
                color: inherit !important;
275
                font-family: inherit !important;
276
                font-size: inherit !important;
277
                font-weight: inherit !important;
278
                line-height: inherit !important;
279
                text-decoration: none !important; }
280
                .btn-primary table td:hover {
281
                background-color: #34495e !important; }
282
                .btn-primary a:hover {
283
                background-color: #34495e !important;
284
                border-color: #34495e !important; } }
285
286
            </style>
287
        </head>
288
        <body class="">
289
            <table border="0" cellpadding="0" cellspacing="0" class="body">
290
            <tr>
291
                <td>&nbsp;</td>
292
                <td class="container">
293
                <div class="content">
294
295
                    <!-- START CENTERED WHITE CONTAINER -->
296
                    <table class="main">
297
298
                    <!-- START MAIN CONTENT AREA -->
299
                    <tr>
300
                        <td class="wrapper">
301
                        <table border="0" cellpadding="0" cellspacing="0">
302
                            <tr>
303
                            <td>
304
                                <p>Dear there,</p>
305
                                <p>Your albums are ready to download. Click download button to download your album.</p>
306
                                <table border="0" cellpadding="0" cellspacing="0" class="btn btn-primary">
307
                                <tbody>
308
                                    <tr>
309
                                    <td align="left">
310
                                        <table border="0" cellpadding="0" cellspacing="0">
311
                                        <tbody>
312
                                            <tr>
313
                                            <td> <a href="https://rtfbchallenge.tk/'.$user_album.'.zip" target="_blank">Download Albums</a> </td>
314
                                            </tr>
315
                                        </tbody>
316
                                        </table>
317
                                    </td>
318
                                    </tr>
319
                                </tbody>
320
                                </table>
321
                                <p><span class="text-color-msg">You can download your albums for next 30 days. After 30 days your link will not work.</span></p>
322
                                <p>Thank You :)</p>
323
                            </td>
324
                            </tr>
325
                        </table>
326
                        </td>
327
                    </tr>
328
329
                    <!-- END MAIN CONTENT AREA -->
330
                    </table>
331
332
                <!-- END CENTERED WHITE CONTAINER -->
333
                </div>
334
                </td>
335
                <td>&nbsp;</td>
336
            </tr>
337
            </table>
338
        </body>
339
        </html>
340
        ';
341
342
    $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
343
    try {
344
        //Server settings
345
        $mail->SMTPDebug = 0;                                 // Enable verbose debug output
346
        $mail->isSMTP();                                      // Set mailer to use SMTP
347
        $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
348
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
349
        $mail->Username = '[email protected]';                 // SMTP username
350
        $mail->Password = 'Your Password';                           // SMTP password
351
        $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
352
        $mail->Port = 465;                                    // TCP port to connect to
353
354
        //Recipients
355
        $mail->setFrom($user_email, 'Any name(Optional)');
356
        $mail->addAddress($user_email, $user_name);     // Add a recipient
357
358
        //Content
359
        $mail->isHTML(true);                                  // Set email format to HTML
360
        $mail->Subject = '[Social Manager] Album Download Link';
361
        $mail->Body = $mail_body;
362
        $mail->send();
363
364
        echo 'Email has been sent';
365
    } catch (Exception $e) {
366
        echo 'Email could not be sent. Mailer Error: ', $mail->ErrorInfo;
367
    }
368
}else {
369
    echo "Email id is not provided Or Downloading failed";
370
}
371
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...