Setting up Outbound email


#1

I used to be able to configure a customer email in /phabricator/htdocs/conf/custom/PhabricatorMail.conf.php
After I have updated the Phabricator, it seems the /htdocs/conf doesn’t have the custom folder anymore.

How can i configure the mailing such that today i use the following?

<?php return array( 'phpmailer.smtp-host' => '10.10.5.1', 'phpmailer.smtp-port' => 30, );

#2

Phabricator never had an /htdocs/ directory - there’s /conf/, maybe that’s what you’re talking about? And I don’t remember any mention of /custom/ directory being loaded.

Anyway, all configuration is done either via the web app (Navigate to Config application) or using the ./bin/config script in /phabricator/.

There’s more advanced stuff in https://secure.phabricator.com/book/phabricator/article/advanced_configuration/ .


#3

I’ve found some code that refers to .conf.php, but the last change that’s even remotely related to it is 3 years old.


#4

avivey, thanks! Yes, i believe PhabricatorMail.conf.php probably was 3 years old. I have recently upgraded to the latest and it probably doesn’t exist anymore either.
I’ve checked in the PHPMailer config, and also the mailer config, it does look like all the mailer settings are in place.
Question to now why are the mail stuck in the outbound. I checked it using the following command:
./bin/mail list-outbound

Here are my settings:

metamta.mail-adapter => PhabricatorMailImplementationPHPMailerAdapter

phpmailer.mailer => “smtp”
phpmailer.smtp-host => “10.10.5.1"”
phpmailer.smtp-port => 25
phpmailer.smtp-protocol => “tls”
phpmailer.smtp-user => null
phpmailer.smtp-password => “base64”


#5

I found out where the custom is recommended, looks like it is in the advanced page.
i guess previously I created a custom file with the mailer information, and wrote it to the ENVIRONMENT.

echo custom/exampleconfig > conf/local/ENVIRONMENT

I thought having the information in the local.json would be sufficient, wouldn’t it?


#6

the local.json should be fine - I think the ENVIRONMENT thing was so you can run several instances in the same server, but I’m not sure if that’s still relevant.

I think there was some change to Mail configuration recently - you should go over https://secure.phabricator.com/w/changelog/ and see if there’s something relevant.


#7

hmm, even though my metamta.mail-adapter => PhabricatorMailImplementationPHPMailerAdapter,
would i need to install phpmailer? or will it utilize the php mail function instead?


#8

I just re-read this phrase multiple time.
At the end of the sentences, it says "This option is deprecated in favor of ‘cluster.mailers’.
So, i guess we shouldn’t be using this option “metamta.mail-adapter” anymore maybe?

Adapter class to use to transmit mail to the MTA. The default uses PHPMailerLite, which will invoke “sendmail”. This is appropriate if sendmail actually works on your host, but if you haven’t configured mail it may not be so great. A number of other mailers are available (e.g., SES, SendGrid, SMTP, custom mailers). This option is deprecated in favor of ‘cluster.mailers’.


#9

I’m not sure how to setup clusters.mailer based off this link below. The link show me the options under Mailer: STMP heading.
https://secure.phabricator.com/book/phabricator/article/configuring_outbound_email/

  1. Do I edit the "local.json " file and just add the following to the back of the file ?
    or
  2. I will create a Mailer.json file in ./conf/custom/Mailer.json

Inside the mailer.json, i have the following:

[
{
“key”:“Test-Mailer”,
“type”: “smtp”,
“options”: {
“host”: “10.10.5.1”,
“post”: 25,
“protocol” : “tls”
}
]

On the bash line, i enter the following:

./bin/config set --stdin < conf/custom/mailer.json

I tried this, but the bash reported with

Usage Exception: Specify a configuration key and a value to set it to.

Not sure what to do next. I have my key and value, but it still report error.


#10

Maybe they want me to specify the options this way instead?

[
{
“key”:“Test-Mailer”,
“type”: “smtp”,
“host”: “10.10.5.1”,
“post”: 25,
“protocol” : “tls”
}
]

That still did not work as i got the following:

Usage Exception: Specify a configuration key and a value to set it to.


#11

Here are some notes on logic change https://secure.phabricator.com/D19004 in regards to the cluster.mailers.
my files are the same update as what they have there.

I have decided to disable sethidden parameter to false in the following file : PhabricatorMetaMTAConfigOptions.php, and configure it in the phabricator with the following:

[
  {
    “key”:“Test-Mailer”,
    “type”: “smtp”,
    “options”: {
      “host”: “10.10.5.1”,
      “post”: 25,
      “protocol” : “tls”
    }
  }
]

The UI accepted the following json.
Reboot the machine, and still not working.
The mails are still pending in queue.

I have cluster.mail setup. I have the mta setup as well.
What else is missing?


#12

Are the daemons running?


#13

Hmm, which daemon would i want to see running ?
This is what i have for the daemons.

user@debian:~$ ps aux | grep daemon
daemon 286 0.0 0.1 27964 2100 ? Ss Apr06 0:00 /usr/sbin/atd -f
daemon 40328 0.1 1.2 151512 25916 ? Ss 17:33 0:00 /opt/php/bin/php.bin ./phd-daemon
daemon 40384 0.6 2.1 308188 44672 ? S 17:33 0:02 php-fpm: pool phabricator
daemon 40412 0.0 0.8 1763488 17760 ? Sl 17:33 0:00 /opt/apache2/bin/httpd.bin -f /opt/apache2/conf/httpd.conf
daemon 40413 0.0 0.8 1763292 17604 ? Sl 17:33 0:00 /opt/apache2/bin/httpd.bin -f /opt/apache2/conf/httpd.conf
daemon 40414 0.0 1.0 1763292 21656 ? Sl 17:33 0:00 /opt/apache2/bin/httpd.bin -f /opt/apache2/conf/httpd.conf
daemon 40643 0.0 1.1 1763292 24240 ? Sl 17:33 0:00 /opt/apache2/bin/httpd.bin -f /opt/apache2/conf/httpd.conf
daemon 40720 0.4 2.2 309740 46620 ? S 17:34 0:01 php-fpm: pool phabricator
daemon 40790 0.4 2.4 311940 49264 ? S 17:35 0:01 php-fpm: pool phabricator
daemon 40890 0.3 2.3 311716 48332 ? S 17:36 0:00 php-fpm: pool phabricator
daemon 40974 0.1 1.9 309412 39640 ? S 17:37 0:00 php-fpm: pool phabricator


#14

Phabricator daemons. in the web ui, navigate to /daemons and you’ll see a status of daemons and task backlog.


#15

Found it.


#16

PhabricatorMetaMTAWorker is an email-sending task; You can see they have hundreds of failures (failed attempts at sending an email).
You should be able to see logs and exception detail using ./bin/phd log, and maybe figure out what’s wrong.


#17

Hmm, it just kept repeating. ideas?

Daemon 5665 STDE [Tue, 10 Apr 2018 07:47:33 -0400] #8 <#2> PhabricatorWorkerActiveTask::executeTask() called at [/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php:22]
Daemon 5665 STDE [Tue, 10 Apr 2018 07:47:33 -0400] #9 PhabricatorTaskmasterDaemon::run() called at [/src/daemon/PhutilDaemon.php:219]
Daemon 5665 STDE [Tue, 10 Apr 2018 07:47:33 -0400] #10 PhutilDaemon::execute() called at [/scripts/daemon/exec/exec_daemon.php:131]
Daemon 5665 FAIL [Tue, 10 Apr 2018 07:47:33 -0400] Process exited with error 255.
Daemon 5665 WAIT [Tue, 10 Apr 2018 07:47:33 -0400] Waiting 5 second(s) to restart process.
Daemon 5729 INIT [Tue, 10 Apr 2018 07:47:36 -0400] Starting process.
Daemon 5665 INIT [Tue, 10 Apr 2018 07:48:12 -0400] Starting process.
Daemon 5729 DONE [Tue, 10 Apr 2018 07:47:37 -0400] Process exited normally.
Daemon 5665 ZZZZ [Tue, 10 Apr 2018 07:47:54 -0400] Process is preparing to hibernate for 180 second(s).
Daemon 5665 DONE [Tue, 10 Apr 2018 07:47:54 -0400] Process exited normally.
Daemon 5665 WAIT [Tue, 10 Apr 2018 07:47:54 -0400] Waiting 180 second(s) to restart process.
Daemon 5663 INIT [Tue, 10 Apr 2018 07:50:08 -0400] Starting process.
Daemon 5664 INIT [Tue, 10 Apr 2018 07:50:08 -0400] Starting process.
Daemon 5663 ZZZZ [Tue, 10 Apr 2018 07:50:08 -0400] Process is preparing to hibernate for 180 second(s).
Daemon 5663 DONE [Tue, 10 Apr 2018 07:50:08 -0400] Process exited normally.
Daemon 5663 WAIT [Tue, 10 Apr 2018 07:50:08 -0400] Waiting 180 second(s) to restart process.
Daemon 5664 ZZZZ [Tue, 10 Apr 2018 07:50:08 -0400] Process is preparing to hibernate for 180 second(s).
Daemon 5664 DONE [Tue, 10 Apr 2018 07:50:08 -0400] Process exited normally.
Daemon 5664 WAIT [Tue, 10 Apr 2018 07:50:08 -0400] Waiting 180 second(s) to restart process.


#18
Daemon 5665 STDE [Tue, 10 Apr 2018 07:47:33 -0400] #8 <#2> PhabricatorWorkerActiveTask::executeTask() called at [/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php:22]

This is the last line of a stack trace.

You can try running ./bin/worker execute --trace to execute a task outside of a daemon, so you’ll get the full error message.


#19

Hmm, the issue seems to be caused by the host not having a valid SSL certificate.
Do i actually need a ssl certificate if the protocol is set to TLS ?


#20

Yeah, you need to have certs on your machines so you can verify the remote host is who it claims it is. The OS will usually ship with several “root” certificates that it trusts, and any time you try to establish TLS connection, it will compare the remote’s certificates to the ones you have. It’s possible that your certs expired, or that the remote is using a certificate providers your OS doesn’t identify - it shouldn’t be to hard to add/update your cert collection.