# Sendmail not working properly with curl for http-auth



## cbichis (Mar 11, 2011)

Hello,

We are trying to send the output of a http-authed page by sendmail. Below is the command:

`/usr/local/bin/curl [url]http://www.domain.com/httpauth-protected-page[/url] --basic --user username:apass | /usr/sbin/sendmail [email]email@domain.com[/email]`

However, it seems only if we add a --trace-ascii - to the *curl* command I can get the output to be sent by sendmail. Otherwise the email body is blank.


If the page accessed by CURL is not protected by http-auth then the command

`/usr/local/bin/curl [url]http://www.domain.com/non-protected-page[/url] | /usr/sbin/sendmail [email]email@domain.com[/email]`

works perfectly. The webpage source is sent in email body.


Any idea how to fix this (FreeBSD 8.1)? I can do other ways (by example output curl content to file and email after) but I prefer to keep the command as simple as possible.


----------



## gordon@ (Mar 11, 2011)

Use mail instead of sendmail:

`% /usr/local/bin/curl [url]http://www.domain.com/non-protected-page[/url] | mail -s "Subject" [email]email@domain.com[/email]`

Sendmail allows you to set headers and what have you. You should be using mail as it will behave a little more like you expect.


----------

