noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
smtpmail.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20// Copyright Author Dany De Bontridder danydb@noalyss.eu 21.10.2025
21
22namespace Noalyss;
23
24/**
25 * @file
26 * @brief
27 */
28use PHPMailer\PHPMailer\PHPMailer;
29use PHPMailer\PHPMailer\SMTP;
30
31/**
32 * @class SMTPMail
33 * @brief
34 */
36{
37
38 protected $phpmailer;
39
40 /**
41 * @param $reply_to
42 * @param $blind_copy
43 */
44 public function __construct(Mail_Parameter $mail_parameter)
45 {
46 $this->phpmailer = new PHPMailer;
47 $this->phpmailer->CharSet = PHPMailer::CHARSET_UTF8;
48
49 //$this->phpmailer->SMTPDebug = SMTP::DEBUG_CONNECTION;
50 $this->phpmailer->SMTPDebug = SMTP::DEBUG_OFF;
51 $this->phpmailer->isSMTP(true);
52 $this->phpmailer->XMailer = "noalyss-email";
53 $this->phpmailer->Host = $mail_parameter->smtp_host;
54 $this->phpmailer->Port = $mail_parameter->smtp_port;
55 $this->phpmailer->Username = $mail_parameter->smtp_user;
56 $this->phpmailer->Password = $mail_parameter->smtp_password;
57 $this->phpmailer->SMTPAuth = ($mail_parameter->smtp_auth == 1) ? true : false;
58 $this->phpmailer->SMTPSecure = $mail_parameter->smtp_secure;
59 $this->phpmailer->setFrom($mail_parameter->smtp_from);
60 $this->phpmailer->SMTPSecure = $mail_parameter->smtp_secure;
61 $this->phpmailer->setFrom($mail_parameter->smtp_from);
62 // $this->phpmailer->addReplyTo($mail_parameter->smtp_replyto);
63 // $this->blind_copy = $blind_copy;
64 $this->phpmailer->isHTML(true);
65 }
66
67 public function getPhpmailer()
68 {
69 return $this->phpmailer;
70 }
71 public function set_from($from)
72 {
73 $this->phpmailer->setFrom($from);
74 }
75 public function setPhpmailer($phpmailer): PHPMailer
76 {
77 $this->phpmailer = $phpmailer;
78 return $this;
79 }
80
81 function set_format($format): SMTPMail
82 {
83 if (strtolower($format) == 'html')
84 {
85 $this->phpmailer->isHTML(true);
86 return $this;
87 }
88 $this->phpmailer->isHTML(false);
89 return $this;
90 }
91
92 /**
93 * @param mixed $blind_copy
94 */
95 public function setBlindCopy($blind_copy): SMTPMail
96 {
97 $this->phpmailer->addBCC($this->blind_copy);
98 return $this;
99 }
100
101 /**
102 * @param mixed $reply_to
103 */
104 public function setReplyTo($reply_to): SMTPMail
105 {
106 $this->phpmailer->addReplyTo($reply_to);
107 return $this;
108 }
109
111 {
112
113 }
114
115 function __toString()
116 {
117
118 }
119
120 function mailto($email): SMTPMail
121 {
122 $a_email = explode(',', $email);
123 foreach ($a_email as $item)
124 {
125 $this->phpmailer->addAddress($item);
126 }
127 return $this;
128 }
129
130 function set_subject($subject): SMTPMail
131 {
132 $this->phpmailer->Subject = $subject;
133 return $this;
134 }
135
137 {
138 $this->phpmailer->Body = $msg;
139 $this->phpmailer->AltBody = \strip_tags($msg);
140 return $this;
141 }
142
143 function add_file(\FileToSend $filename): SMTPMail
144 {
145 $this->phpmailer->addAttachment($filename->full_name);
146 return $this;
147 }
148
149 function compose(): SMTPMail
150 {
151 $this->phpmailer->preSend();
152 return $this;
153 }
154
155 function send(): SMTPMail
156 {
157 $this->phpmailer->send();
158 return $this;
159 }
160}
$from
file to add to a message
configuration email and test PHPMAILER.
__construct(Mail_Parameter $mail_parameter)
setPhpmailer($phpmailer)
add_file(\FileToSend $filename)
setBlindCopy($blind_copy)