Sending mail via sendmail


#1

I configured the mailer to sendmail but it didn’t work. Seems that the only option that works is SMTP.
The following change configures PHPMailer to use sendmail.

diff --git a/app/sprinkles/core/src/Mail/Mailer.php b/app/sprinkles/core/src/Mail/Mailer.php
index 5b346b46..0f9dc9e9 100755
--- a/app/sprinkles/core/src/Mail/Mailer.php
+++ b/app/sprinkles/core/src/Mail/Mailer.php
@@ -48,7 +48,9 @@ class Mailer
                 throw new \phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'.");
             }
 
-            if ($config['mailer'] == 'smtp') {
+            if ($config['mailer'] == 'sendmail') {
+                $this->phpMailer->isSendmail();
+            } else if ($config['mailer'] == 'smtp') {
                 $this->phpMailer->isSMTP(true);
                 $this->phpMailer->Host =       $config['host'];
                 $this->phpMailer->Port =       $config['port'];
    `indent preformatted text by 4 spaces`

#2

My interest is in sendmail support but I don’t think the options of “mail” or “qmail” are going to work.
A better patch is the following (mail and qmail are untested):

diff --git a/app/sprinkles/core/src/Mail/Mailer.php b/app/sprinkles/core/src/Mail/Mailer.php
index 5b346b46..b25873f5 100755
--- a/app/sprinkles/core/src/Mail/Mailer.php
+++ b/app/sprinkles/core/src/Mail/Mailer.php
@@ -44,11 +44,17 @@ class Mailer
 
         // Configuration options
         if (isset($config['mailer'])) {
-            if (!in_array($config['mailer'], ['smtp', 'mail', 'qmail', 'sendmail'])) {
-                throw new \phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'.");
-            }
-
-            if ($config['mailer'] == 'smtp') {
+			switch ($config['mailer']) {
+			case 'mail':
+                $this->phpMailer->isMail();
+				break;
+			case 'qmail':
+                $this->phpMailer->isQmail();
+				break;
+			case 'sendmail':
+                $this->phpMailer->isSendmail();
+				break;
+			case 'smtp':
                 $this->phpMailer->isSMTP(true);
                 $this->phpMailer->Host =       $config['host'];
                 $this->phpMailer->Port =       $config['port'];
@@ -61,6 +67,9 @@ class Mailer
                 if (isset($config['smtp_options'])) {
                     $this->phpMailer->SMTPOptions = $config['smtp_options'];
                 }
+				break;
+			default:
+                throw new \phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'.");
             }
 
             // Set any additional message-specific options

#3

Submit a pull request? https://help.github.com/articles/about-pull-requests/


#4

Done.