Getting the following error on a drush scripted install

WD user: Session opened for admin. [6.44 sec, 21.33 MB] [notice]
sh: 1: -t: not found
WD mail: Error sending e-mail (from drmiaow@gmail.com to drmiaow@gmail.com). [8.36 sec, 21.15 MB] [error]
WD cron: Cron run completed. [8.37 sec, 21.14 MB] [notice]
Unable to send e-mail. Contact the site administrator if the problem persists. [8.38 sec, 21.13 MB] [error]
Command dispatch complete [8.38 sec, 21.11 MB] [notice]
Timer Cum (sec) Count Avg (msec)
page 8.286 1 8286.17
drupal_http_request 1.007 1 1007.47

Does anyone know how to please stop Drush/Drupal from sending an email on site-install?

Thanks.

Comments

DrMiaow’s picture

Title: How to stop drush from on site-install when email is not available. » How to stop Drush from sending email on site-install when email is not available.
moshe weitzman’s picture

Status: Active » Fixed

Drupal is doing this. We fixed this with a php.ini setting in our CI setup. Some pseudocode: php -d sendmail_path=/dev/null drush ....

patcon’s picture

DrMiaow’s picture

I get

sh: 1: /dev/null: Permission denied

DrMiaow’s picture

And under linux if I point it at /usr/sbin/sendmail instead of /dev/null I get

Recipient names must be specified
WD mail: Error sending e-mail (from log@MYDOMAIN.com to log@MYDOMAIN.com). [13.2 sec, 21.15 MB] [error]
WD cron: Cron run completed. [13.24 sec, 21.15 MB] [notice]
Unable to send e-mail. Contact the site administrator if the problem persists. [13.25 sec, 21.14 MB] [error]
Command dispatch complete [13.25 sec, 21.11 MB]

greg.1.anderson’s picture

Maybe try php -d sendmail_path=/path/to/executable/that/does/nothing, and then make an executable file that contains only:

#!/bin/bash

exit 0
DrMiaow’s picture

Thanks.

In the end I opted for

php -d sendmail_path=`which true` ...

which expanded to

php -d sendmail_path=/bin/true ...

Which did the same as you suggested, without the need for a fake app the returns true.

Does not solve the issue for Windows though, but at least I have something to go on.

Thanks Again!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

cantoute’s picture

Project: Drush » PHP Configuration
Version: » 7.x-1.0
Component: Core Commands » Miscellaneous
Issue tags: +Just a precision on previous comments

This is an old question, but for next one looking for how to block php mail function
(perhaps that information would have a better place on the wordpress documentation... it's actually to block wordpress sites turning into spam machines that i use that

no need to create that script

#!/bin/bash
exit 0

is part of unix base and is called /bin/true

in php.ini
sendmail_path=/bin/true

Under unix, process that exits with a non zero value indicate it failed

so to block mails silently (php will believe the mail is sent) you would want /bin/true
if you want php to know that sent has failed then replace with /bin/false

hawkeye.twolf’s picture

For others who stumble across this, one part that wasn't totally obvious to me: You need to pass in the actual drush.php script instead of the drush binary.

php -d sendmail_path=`which true` /path/to/drush.php site-install ...

In my vagrant box, drush.php was at /usr/share/php/drush/drush.php

greg.1.anderson’s picture

Calling drush.php is deprecated. Instead, do this:

/usr/bin/env PHP_OPTIONS='d sendmail_path=`which true`' drush site-install

hawkeye.twolf’s picture

Thanks Greg! Yes that would be much better. But it doesn't work for me on Drush 6.2, 6.5, or 7-alpha6. With the code you posted, I get "Could not open input file: d".

I think you missed a dash in front of the "d" in
PHP_OPTIONS='d sendmail_path=`which true`'

But after fixing it I still get "Could not open input file: true`"

Any ideas? Thanks.

greg.1.anderson’s picture

Sorry for the typos!

Test:

/usr/bin/env PHP_OPTIONS="-d sendmail_path=`which true`" drush ev 'return ini_get("sendmail_path");'

So, for site install, then, use this:

/usr/bin/env PHP_OPTIONS="-d sendmail_path=`which true`" drush site-install ...

hawkeye.twolf’s picture

The double quotes fixed it. Thanks!

guardian87’s picture

Just used this on a CI setup on codeship.
Works like charm!

Thanks for this.

JulienD’s picture

@guardian87 which version of PHP and Drush do you use? I work for me on 5.6 but not on php 7.

Edit: I had to update to the latest version of Drush using composer instead of the Phar build. Worked like a charm in this case.

jasonawant’s picture

FWIW, you can use the following to disable the email notification.

Disable email notification during install and later. If your server has no smtp, this gets rid of an error during install.

drush site-install standard install_configure_form.update_status_module='array(FALSE,FALSE)'

https://drushcommands.com/drush-8x/core/site-install/

jasonawant’s picture

In 8.3.x, the SiteConfigureForm form structured changed, so now it's

drush site-install standard install_configure_form.enable_update_status_module=NULL

See https://github.com/drush-ops/drush/pull/2675 and https://github.com/drush-ops/drush/pull/2676

Anonymous’s picture

@jasonawant ++ for this info. My CI setup was failing because of the failed email during installation.

twfahey’s picture

Thank you @jasonawant

natts’s picture

Thank you also @jasonawant. Instead of messing around trying to set-up e-mail on Windows IIS, I can just use your:

install_configure_form.update_status_module='array(FALSE,FALSE)'

argument on my 'drush si profile-name' command (for D7).