Last change
on this file was e3d4e0a, checked in by Vlado 222039 <vlado.popovski@…>, 6 days ago |
Upload project files
|
-
Property mode
set to
100644
|
File size:
966 bytes
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | use PHPMailer\PHPMailer\PHPMailer;
|
---|
4 | use PHPMailer\PHPMailer\Exception;
|
---|
5 |
|
---|
6 | require 'vendor/autoload.php';
|
---|
7 |
|
---|
8 | function SendMail($address, $subject, $body) {
|
---|
9 | try {
|
---|
10 | $mail = new PHPMailer(true);
|
---|
11 | // Server settings
|
---|
12 | $mail->isSMTP();
|
---|
13 | $mail->Host = 'smtp.gmail.com'; //SMTP server
|
---|
14 | $mail->SMTPAuth = true;
|
---|
15 | $mail->Username = ''; //email address
|
---|
16 | $mail->Password = ''; // app password
|
---|
17 | $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
---|
18 | $mail->Port = 587;
|
---|
19 |
|
---|
20 | $mail->setFrom('', 'Innova');
|
---|
21 | $mail->addAddress("{$address}");
|
---|
22 |
|
---|
23 | $mail->Subject = $subject;
|
---|
24 | $mail->Body = $body;
|
---|
25 |
|
---|
26 | $mail->send();
|
---|
27 | echo 'Message has been sent';
|
---|
28 | } catch (Exception $e) {
|
---|
29 | echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
---|
30 | }
|
---|
31 | }
|
---|
32 | ?> |
---|
Note:
See
TracBrowser
for help on using the repository browser.