apprentice workflow completed
[brisk.git] / web / Obj / mail.phh
1 <?php
2 if (isset($argv) && __FILE__ == realpath($argv[0])) {
3     $G_base = "web/";
4 }
5 require_once("${G_base}Obj/class.phpmailer.php");
6
7 function brisk_mail($to, $subject, $text, $html)
8 {
9     GLOBAL $G_admin_mail;
10
11     $mail = new PHPMailer(TRUE);
12     $mail->CharSet = "UTF-8";
13
14     $mail->From = $G_admin_mail;
15     $mail->FromName = 'Brisk Admin';
16     $mail->addAddress($to);     // Add a recipient
17     $mail->addReplyTo($G_admin_mail, 'Brisk Admin');
18
19     $mail->Subject = $subject;
20     $mail->AltBody = $text;
21
22     $body_html = sprintf("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>%s</title></head><body>%s</body></html>",
23                              $subject, $html);
24
25     $mail->MsgHTML($body_html);
26
27
28     return ($mail->Send());
29 }
30
31
32 if (isset($argv) && __FILE__ == realpath($argv[0])) {
33     $G_admin_mail = "brisk@alternativeoutput.it";
34
35     $to = "brisk@alternativeoutput.it";
36     $subject = "Brisk: credenziali di accesso.";
37     $body_txt = "Ciao, sono l' amministratore del sito di Brisk.
38
39 La verifica del tuo indirizzo di posta elettronica e del tuo nickname è andata a buon fine, per accedere al sito
40 d'ora in poi potrai utilizzare l' utente 'mopz' e la password 'ienxedsiyndo'.
41
42 Benvenuto e buone partite, mop.";
43     $body_htm = "Ciao, sono l' amministratore del sito di Brisk.<br><br>
44 La verifica del tuo indirizzo di posta elettronica e del tuo nickname è andata a buon fine, per accedere al  sito d'ora in poi potrai usare l' utente 'mopz' e la password 'ienxedsiyndo'.<br>
45 Benvenuto e buone partite, mop.<br>";
46
47     $body_htm_full = sprintf("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>%s</title></head><body>%s</body></html>",
48                              $subject, $body_htm);
49
50
51     if (brisk_mail("brisk@alternativeoutput.it", $subject, $body_txt, $body_htm)) {
52         echo "SUCCESS";
53     }
54     else {
55         echo "ERROR";
56     }
57 }
58 ?>