File modules/util/mail/client/SendmailClient.class.php

Last commit: Wed Oct 27 02:27:59 2021 +0200	Jan Dankert	Refactoring: Splitted the mail client into a.) sendmail and b.) smtp.
1 <?php 2 // OpenRat Content Management System 3 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 2 8 // of the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 namespace util\mail\client; 20 21 use cms\base\Configuration; 22 use cms\base\Language; 23 use cms\base\Startup; 24 use LogicException; 25 use util\text\TextMessage; 26 use util\text\variables\VariableResolver; 27 28 /** 29 * Erzeugen und Versender einer E-Mail gemaess RFC 822.<br> 30 * <br> 31 * Die E-Mail kann entweder �ber 32 * - die interne PHP-Funktion "mail()" versendet werden oder 33 * - direkt per SMTP-Protokoll an einen SMTP-Server.<br> 34 * Welcher Weg gew�hlt wird, kann konfiguriert werden.<br> 35 * <br> 36 * Prinzipiell spricht nichts gegen die interne PHP-Funktion mail(), wenn diese 37 * aber nicht zu Verf�gung steht oder PHP ungeeignet konfiguriert ist, so kann 38 * SMTP direkt verwendet werden. Hierbei sollte wenn m�glich ein Relay-Host 39 * eingesetzt werden. Die Mail kann zwar auch direkt an Mail-Exchanger (MX) des 40 * Empf�ngers geschickt werden, falls dieser aber Greylisting einsetzt ist eine 41 * Zustellung nicht m�glich.<br> 42 * <br> 43 * 44 * @author Jan Dankert 45 */ 46 class SendmailClient implements Client 47 { 48 49 /** 50 * Mail absenden. 51 * Die E-Mail wird versendet. 52 */ 53 public function send($to, $subject, $body, $headers) 54 { 55 56 // PHP-interne Mailfunktion verwenden. 57 $result = @mail($to, // Empf�nger 58 $subject, // Betreff 59 $body, // Inhalt 60 // Lt. RFC822 müssen Header mit CRLF enden. 61 // ABER: Der Parameter "additional headers" verlangt offenbar \n am Zeilenende. 62 implode("\n", $headers)); 63 if (!$result) 64 // Die E-Mail wurde nicht akzeptiert. 65 // Genauer geht es leider nicht, da mail() nur einen boolean-Wert 66 // zur�ck liefert. 67 throw new LogicException('Mail was NOT accepted by mail(), no further information available. Please look into your system logs.'); 68 } 69 }
Download modules/util/mail/client/SendmailClient.class.php
History Wed, 27 Oct 2021 02:27:59 +0200 Jan Dankert Refactoring: Splitted the mail client into a.) sendmail and b.) smtp.