<defaultvalue>php</defaultvalue>
<selectoptions>php:wcf.acp.option.mail_send_method.php
smtp:wcf.acp.option.mail_send_method.smtp
-debug:wcf.acp.option.mail_send_method.debug</selectoptions>
+debug:wcf.acp.option.mail_send_method.debug
+debugFolder:wcf.acp.option.mail_send_method.debugFolder</selectoptions>
<enableoptions>php:mail_use_f_param,!mail_smtp_host,!mail_smtp_port,!mail_smtp_starttls,!mail_smtp_user,!mail_smtp_password
smtp:!mail_use_f_param,mail_smtp_host,mail_smtp_port,mail_smtp_starttls,mail_smtp_user,mail_smtp_password
-debug:!mail_use_f_param,!mail_smtp_host,!mail_smtp_port,!mail_smtp_starttls,!mail_smtp_user,!mail_smtp_password</enableoptions>
+debug:!mail_use_f_param,!mail_smtp_host,!mail_smtp_port,!mail_smtp_starttls,!mail_smtp_user,!mail_smtp_password
+debugFolder:!mail_use_f_param,!mail_smtp_host,!mail_smtp_port,!mail_smtp_starttls,!mail_smtp_user,!mail_smtp_password</enableoptions>
</option>
<option name="mail_smtp_host">
<categoryname>general.mail.send</categoryname>
--- /dev/null
+<?php
+namespace wcf\system\email\transport;
+use wcf\system\email\Email;
+use wcf\system\email\Mailbox;
+use wcf\util\FileUtil;
+
+/**
+ * DebugFolderEmailTransport is a debug implementation of an email transport which writes emails into
+ * a folder.
+ * On unix-like operating systems the folder will be a valid Maildir.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Email\Transport
+ * @since 5.2
+ */
+class DebugFolderEmailTransport implements IEmailTransport {
+ /**
+ * folder
+ * @var string
+ */
+ protected $folder = null;
+
+ /**
+ * Creates a new DebugFolderTransport using the given folder as target.
+ *
+ * @param string $folder folder or null for default folder
+ */
+ public function __construct($folder = null) {
+ if ($folder === null) $folder = WCF_DIR.'log/Maildir';
+
+ $this->folder = FileUtil::addTrailingSlash($folder);
+ FileUtil::makePath($this->folder);
+ if (PHP_EOL != "\r\n") {
+ FileUtil::makePath($this->folder.'new');
+ FileUtil::makePath($this->folder.'cur');
+ FileUtil::makePath($this->folder.'tmp');
+ }
+ }
+
+ /**
+ * Writes the given $email into the folder.
+ *
+ * @param Email $email
+ * @param Mailbox $envelopeFrom
+ * @param Mailbox $envelopeTo
+ */
+ public function deliver(Email $email, Mailbox $envelopeFrom, Mailbox $envelopeTo) {
+ $eml = "Return-Path: <".$envelopeFrom->getAddress().">\r\n";
+ $eml .= "Delivered-To: <".$envelopeTo->getAddress().">\r\n";
+ $eml .= $email->getEmail();
+ $eml .= "\r\n";
+ $timestamp = explode(' ', microtime());
+ $filename = $timestamp[1].'.M'.substr($timestamp[0], 2).'.eml';
+ file_put_contents($this->folder.$filename, $eml);
+
+ if (PHP_EOL != "\r\n") {
+ symlink('../'.$filename, $this->folder.'new/'.$filename);
+ }
+ }
+}
'exception_privacy'
]);
$statement->execute([
- 'debug',
+ 'debugFolder',
'mail_send_method'
]);
$statement->execute([
<item name="wcf.acp.option.mail_from_name"><![CDATA[Absender-Name]]></item>
<item name="wcf.acp.option.mail_from_name.description"><![CDATA[Absender-Name für automatisch generierte E-Mails]]></item>
<item name="wcf.acp.option.mail_send_method"><![CDATA[Versandmethode]]></item>
- <item name="wcf.acp.option.mail_send_method.debug"><![CDATA[Debug]]></item>
+ <item name="wcf.acp.option.mail_send_method.debug"><![CDATA[Debug (mbox)]]></item>
+ <item name="wcf.acp.option.mail_send_method.debugFolder"><![CDATA[Debug (Ordner mit .eml-Dateien)]]></item>
<item name="wcf.acp.option.mail_send_method.php"><![CDATA[PHP]]></item>
<item name="wcf.acp.option.mail_send_method.smtp"><![CDATA[SMTP]]></item>
<item name="wcf.acp.option.mail_signature"><![CDATA[Signatur]]></item>
<item name="wcf.acp.option.mail_from_name"><![CDATA[Sender’s Name]]></item>
<item name="wcf.acp.option.mail_from_name.description"><![CDATA[The sender’s name for all generated emails.]]></item>
<item name="wcf.acp.option.mail_send_method"><![CDATA[Send Method]]></item>
- <item name="wcf.acp.option.mail_send_method.debug"><![CDATA[Use Debug]]></item>
+ <item name="wcf.acp.option.mail_send_method.debug"><![CDATA[Use Debug (mbox)]]></item>
+ <item name="wcf.acp.option.mail_send_method.debugFolder"><![CDATA[Use Debug (Folder with .eml files)]]></item>
<item name="wcf.acp.option.mail_send_method.php"><![CDATA[Use PHP]]></item>
<item name="wcf.acp.option.mail_send_method.smtp"><![CDATA[Use SMTP]]></item>
<item name="wcf.acp.option.mail_signature"><![CDATA[Sender’s Signature]]></item>