-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_mail.php
63 lines (54 loc) · 2.81 KB
/
send_mail.php
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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function sendMail($SMusername,$SMname,$SMsurname){
//require 'PHPMailerAutoload.php';
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
//$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->Port = 465;
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'Geografi1'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->From = '[email protected]';
$mail->FromName = utf8_decode('Città Alta Plurale');
$mail->addAddress($SMusername, $SMname . " " . $SMsurname); // Add a recipient
//$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Informazioni');
// $mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
$mail->WordWrap = 50; // Set word wrap to 50 characters
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
// ."\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"
$mail->Subject = utf8_decode('Registrazione Città Alta Plurale');
$code = hash("crc32b", $SMusername); // Creates a code from the mail
$mail->Body = utf8_decode("Benvenuto " . $SMname . ",<BR><BR>"
."Per procedere alla registrazione sul sistema partecipativo di Città Alta plurale, <BR>"
. "ti servirà il seguente codice: <BR> <b>".$code."</b>"
."<BR> Grazie per la collaborazione!");
$mail->AltBody = utf8_decode("Benvenuto " . $SMname . ",\n\n"
."Per procedere alla registrazione sul sistema partecipativo di Città Alta Futura, \n"
. "ti servirà il seguente codice: \n".$code
."\n Grazie per la collaborazione!");
if(!$mail->send()) {
// echo 'Message could not be sent.';
return 'Mailer Error: ' . $mail->ErrorInfo;
} else {
return 'OK';
}
}
?>