snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Not able to use sendmail without the -bs flag

Open simonshtipelman opened this issue 11 years ago • 21 comments

Hello,

I was setting up the mail portion of snipeit and ran into a problem with using sendmail. When I select the driver to be sendmail: 'driver' => 'sendmail' and remove the -bs flag from: 'sendmail' => '/usr/sbin/sendmail -bs', I get the following error when trying to have the system send me an email to reset my password: Swift_TransportException Unsupported sendmail command flags [/usr/sbin/sendmail]. Must be one of "-bs" or "-t" but can include additional flags. The file that is throwing the error is: /var/www/html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php

If you need anything else from me, let me know

simonshtipelman avatar Mar 05 '15 21:03 simonshtipelman

Hi @phantomofrussia - can you paste your mail.php file here (obscuring any private information like passwords, etc)

snipe avatar Mar 05 '15 21:03 snipe

Also can you tell me what OS and version of Snipe-IT you're using?

snipe avatar Mar 05 '15 21:03 snipe

Sure thing! I am using Ubuntu Server 14.04 64bit Snipe-IT version is 1.2.6 mail.php:

'sendmail', /* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Postmark mail service, which will provide reliable delivery. | */ 'host' => 'smtp.company.com', /* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to delivery e-mails to | users of your application. Like the host we have set this value to | stay compatible with the Postmark e-mail application by default. | */ 'port' => 25, /* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mails sent by your application to be sent from | the same address. Here, you may specify a name and address that is | used globally for all e-mails that are sent by your application. | */ 'from' => array('address' => '[email protected]', 'name' => 'DONOTREPLY'), /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when | the application send e-mail messages. A sensible default using the | transport layer security protocol should provide great security. | */ 'encryption' => 'tls', /* |-------------------------------------------------------------------------- | SMTP Server Username |-------------------------------------------------------------------------- | | If your SMTP server requires a username for authentication, you should | set it here. This will get used to authenticate with your server on | connection. You may also set the "password" value below this one. | */ 'username' => 'username', /* |-------------------------------------------------------------------------- | SMTP Server Password |-------------------------------------------------------------------------- | | Here you may set the password required by your SMTP server to send out | messages from your application. This will be given to the server on | connection so that the application will be able to send messages. | */ 'password' => '*************', /* |-------------------------------------------------------------------------- | Sendmail System Path |-------------------------------------------------------------------------- | | When using the "sendmail" driver to send e-mails, we will need to know | the path to where Sendmail lives on this server. A default path has | been provided here, which will work well on most of your systems. | */ 'sendmail' => '/usr/sbin/sendmail', /* |-------------------------------------------------------------------------- | Mail "Pretend" |-------------------------------------------------------------------------- | | When this option is enabled, e-mail will not actually be sent over the | web and will instead be written to your application's logs files so | you may inspect the message. This is great for local development. | */ 'pretend' => false, ``` );

simonshtipelman avatar Mar 05 '15 21:03 simonshtipelman

What happens when you set 'username' => 'username', to blank, like 'username' => '',?

snipe avatar Mar 05 '15 21:03 snipe

Also, anything in your mail logs?

snipe avatar Mar 05 '15 21:03 snipe

after making the username blank I get the same result: Swift_TransportException Unsupported sendmail command flags [/usr/sbin/sendmail]. Must be one of "-bs" or "-t" but can include additional flags.

I am able to send emails using this command in the terminal without problems: echo "My test email being sent from sendmail" | /usr/sbin/sendmail [email protected]

simonshtipelman avatar Mar 05 '15 22:03 simonshtipelman

From the Swiftmail docs:

You can run the Sendmail Transport in two different modes specified by command line flags:

"-bs" runs in SMTP mode so theoretically it will act like the SMTP Transport "-t" runs in piped mode with no feedback, but theoretically faster, though not advised You can think of the Sendmail Transport as a sort of asynchronous SMTP Transport -- though if you have problems with delivery failures you should try using the SMTP Transport instead. Swift Mailer isn't doing the work here, it's simply passing the work to somebody else (i.e. sendmail).

snipe avatar Mar 05 '15 22:03 snipe

so it looks like swiftmail does not support using sendmail by itself but instead want you to use smtp.

simonshtipelman avatar Mar 05 '15 22:03 simonshtipelman

It does sorta look that way. Sorry :(

snipe avatar Mar 05 '15 22:03 snipe

I still don't believe it.

http://swiftmailer.org/docs/sending.html#the-sendmail-transport

Let me take a swing at figuring out what's going on here.

uberbrady avatar Mar 05 '15 22:03 uberbrady

@uberbrady http://stackoverflow.com/questions/15604027/change-mailing-transport-in-laravel-4

snipe avatar Mar 05 '15 22:03 snipe

thanks for looking into it @snipe .

@uberbrady, appreciate you trying as well.

simonshtipelman avatar Mar 05 '15 22:03 simonshtipelman

looking at the different flags for sendmail, I do not think -t does what swiftmail says it does http://www.sendmail.org/~ca/email/man/sendmail.html:

"-t Read message for recipients. To:, Cc:, and Bcc: lines will be scanned for recipient addresses. The Bcc: line will be deleted before transmission."

from that definition I read it as sendmail reads the message and does not send it.

simonshtipelman avatar Mar 05 '15 22:03 simonshtipelman

hi phantomofrussia

can you check with driver as SMTP and in the username, put the full address i.e [email protected] rather than 'admin'.

let us know how it goes

cheers

joseph

joseph707 avatar Mar 09 '15 16:03 joseph707

Hi @joseph707, Not sure I completely understand what you are asking me to do. SMTP setup for me works just fine, the issue I was having was using sendmail as the driver.

Thanks

simonshtipelman avatar Mar 09 '15 16:03 simonshtipelman

hi @phantomofrussia

Apologies, I completely misunderstood, that you don't have an issue with the SMTP. Let me check with the sendmail, as the setup I have is with SMTP.

regards

joseph

joseph707 avatar Mar 09 '15 16:03 joseph707

I had this same issue and it ended up being that Postfix was installed and set up instead of sendmail. Once sendmail was running the email worked fine.

dbiers avatar Mar 09 '15 17:03 dbiers

I do not have Postfix installed.

@dbierspb could you paste the sendmail system path here. sendmail does work if you have the -bs or the -t flag in there but otherwise it does not.

simonshtipelman avatar Mar 09 '15 17:03 simonshtipelman

@phantomofrussia : here is my path:

[16:24:47] [root@asset ~]$ which sendmail
/usr/sbin/sendmail

@phantomofrussia : here are my current directives in mail.php:

[16:26:18] [root@asset ~]$ cat /path/to/asset/app/config/production/mail.php | grep =\>
    'driver' => 'sendmail',
    'host' => 'localhost',
    'port' => 25,
    'from' => array('address' => '[email protected]', 'name' => 'Asset Mgmt'),
    'encryption' => 'tls',
    'username' => null,
    'password' => null,
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,

Version:

[16:28:35] [root@asset ~]$ rpm -qa | grep sendmail
sendmail-8.14.4-8.el6.x86_64
[16:29:47] [root@asset ~]$ sendmail -d0.4 -bv root | grep Version
Version 8.14.4

dbiers avatar Mar 09 '15 21:03 dbiers

Well, I'm not certain of what I've got - but in my local docker setup, I installed Sendmail, and then tried to send myself a password reset email. They seem to be enqueueing correctly on the machine. They're not actually delivering out of the queue, but they're at least getting in to the queue.

I left the default - /usr/sbin/sendmail -bs - and my copy of sendmail is definitely not listening on port 25 or anything like that.

Just to be sure I actually have it working the way I think I do, I'm going to try to get my docker container to deliver the mail it has enqueued.

uberbrady avatar Mar 10 '15 05:03 uberbrady