Re: sending mail with a script question

2003-04-05 Thread Ken McGlothlen
David Banning <[EMAIL PROTECTED]> writes:

| I am running a php program in a browser which eventually compiles some files
| and emails them to a person of their choosing. The problem is that the system
| identifies the browser user as nobody.
| 
| I send the mail using a line something like;
| 
| cat textfile | mutt -s"Quote/Attachments" -afile1 -afile2 [EMAIL PROTECTED]
| 
| but the problem is that the recipient sees the sender address as from
| "[EMAIL PROTECTED]", when I want it seen as "[EMAIL PROTECTED]".  I have the
| name of the user available in the script but I see no way of running the mail
| script as that person since any browser viewing the system is "nobody".

Well, mutt is moderately inappropriate for this purpose.  On the other hand,
you're also including attachments, which is another problem.

If I recall correctly, PHP has a mail command that you may want to check into.
However, a very simple way of doing it is to use sendmail.  That's what it's
designed for.  Your textfile would have to contain the headers:

From: [EMAIL PROTECTED]
Subject: Quote/Attachments

[contents of textfile]

or you could use

cat headers textfile | sendmail [EMAIL PROTECTED]

Remember, though, that there MUST BE A BLANK LINE between the headers and the
message.  Just make sure the headers file has a blank line at the end.

The MIME attachments are another deal.  For this, you might want to do

# portinstall mpack

mpack is a MIME packing program (it can also send mail, but not with a
different From address, so we'll leave that out for now).  You'd use it like
this:

/usr/local/bin/mpack -o /tmp/textfile.$$ bodytext file1 file2
/bin/cat headerfile /tmp/textfile.$$ | /usr/sbin/sendmail [EMAIL PROTECTED]
/bin/rm textfile.$$

(Note that I'm using explicit paths as a small increase in security.)

Hope that helps.

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Testtool for Sendmail

2003-02-25 Thread Ken McGlothlen
Andreas Widerøe Andersen <[EMAIL PROTECTED]> writes:

| I'm looking for a FreeBSD tool that will automatically test my smtp server
| for relaying. I'm looking for something like the webpage described here:
| http://www.freebsddiary.org/sendmail.php (Testing the relay).

I tend to use external testing services, which perform a variety of tests.

One reputable open-relay tester can be found at

http://www.abuse.net/relay.html

If you want to be a little more daring, you can use ordb.net's relay-tester to
poke your server and see if it's closed.  It does a variety of tests, and then
emails you the results of the tests.

For more information, see

http://www.ordb.net/submit/

The downside to this is that there is a danger that if you *have* an open
relay, it'll be listed in ORDB until it tests clean, and there are delays
before the tests take place.  So consider this course of action only after
you've used abuse.net's tester.  :)



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message


Re: Removing emails from an email file automatically.

2003-02-19 Thread Ken McGlothlen
Dragoncrest <[EMAIL PROTECTED]> writes:

| Is there a simple way to remove a single email from a mail file using an
| automated script of some kind?

Well, it's better to remove them on their way in, with a tool like procmail.

I do have a set of tools I wrote to help one person get out from under his
rather substantial spamload.  I don't know if they'll help, but they might give
you some ideas.  Note that these are not exhaustively written; they're just
very, very cheap hacks that could be improved on.  Needless to say, they're all
intended to be run as root (unless you're working on your own mailbox).

The first is "fromn," which gives you a numbered "from":

#!/bin/sh

from -f $1 | cat -n

For example (dates slightly elided)

$ fromn /var/mail/mcglk
 1  From [EMAIL PROTECTED]  Feb 19 20:02:46 2003
 2  From [EMAIL PROTECTED]  Feb 19 20:05:46 2003
 3  From [EMAIL PROTECTED]  Feb 19 20:05:57 2003
 4  From [EMAIL PROTECTED]  Feb 19 20:06:08 2003
 5  From [EMAIL PROTECTED]  Feb 19 20:06:21 2003
 6  From [EMAIL PROTECTED]  Feb 19 20:06:31 2003
 7  From [EMAIL PROTECTED]  Feb 19 20:06:57 2003
 8  From [EMAIL PROTECTED]  Feb 19 20:08:42 2003
$ _

The second tool I have is "headers"

#!/bin/sh

skip=`dc -e "$2 1 - p"`
formail +"$skip" -1 -s < $1 | formail -X ""

This allows me to see the headers of any particular message without violating
the privacy of the body of the message.  For example:

$ headers /var/mail/mcglk 2
From [EMAIL PROTECTED]  Wed Feb 19 20:05:57 2003
Return-Path: <[EMAIL PROTECTED]>
Delivered-To: [EMAIL PROTECTED]
Received: from shagrat.julianhaight.com (shagrat.julianhaight.com
  [216.127.43.86])
by c3po.artlogix.com (Postfix) with SMTP id 1D8331AA07
for <[EMAIL PROTECTED]>; Wed, 19 Feb 2003 20:05:57 -0800 (PST)
Received: (qmail 13946 invoked from network);
  20 Feb 2003 03:59:44 -
Received: from localhost (HELO spamcop.net) (127.0.0.1)
  by shagrat.julianhaight.com with SMTP; 20 Feb 2003 03:59:44 -
From: SpamCop AutoResponder <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: SpamCop has accepted 1 email for processing
Date: Thu, 20 Feb 2003 03:59:44 GMT
Message-ID: <[EMAIL PROTECTED]>
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
$ _

If I really need to delete a message at this point, I can use /usr/bin/mail to
delete the message by the message number.

Still, much better to use procmail so you don't have to do any of this stuff in
the first place if at all possible.

| Can I setup something that will search a mail file, find a given sender, and
| then just nuke the message without hurting the mail file?

In theory.  Take a look at the manpages for formail (if you have procmail
installed), which can extract headers from specific messages.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: procmail - unsafe for mailing to programs

2003-02-18 Thread Ken McGlothlen
David Banning <[EMAIL PROTECTED]> writes:

| david$ /usr/david/.forward: line 1: "| /usr/local/bin/procmail || exit 75"... 
|Address [EMAIL PROTECTED] is unsafe for mailing to programs

and later

| $ cat .forward
| "| /usr/local/bin/procmail || exit 75"

The manpage suggests

"|exec /usr/local/bin/procmail || exit 75"

I'm not sure whether that's the problem or not.

My .forward file has always been

"|IFS=' '&&p=/usr/local/bin/procmail&&test -f $p&&exec $p -Yf-||exit 75 #mcglk"

which was probably originally in old procmail documentation, but which works
great.

Other than that, all your permissions look fine.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: email addresses used for lists [was: L0phtcrack]

2002-12-24 Thread Ken McGlothlen
"Jimi Thompson" <[EMAIL PROTECTED]> writes:

| That way when I start getting Viagra or penis enlargment offers (and God
| knows I need 'em ;)) addressed to [EMAIL PROTECTED], I can voice a loud
| and provable complaint.

Well, unfortunately, you might be falsely accusing Best Buy, since it's
likely to get hit on a Rumplestiltskin attack.  Far better to include a random
string in the address, such as

[EMAIL PROTECTED]

That's going to be a lot harder to find by randomly trying usernames, and is a
lot more "provable," assuming that you've only given it out once.  :)

This only really helps if you have an explicit alias, rather than just having
[EMAIL PROTECTED] being delivered to you.

Yet another good reason to run your own mail server.  :)


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: Getting Perl scripts to work as mail filters

2002-12-19 Thread Ken McGlothlen
| Bloated in the sense of complexity.  My script is one file; I install it by
| changing one line in /etc/mail/aliases.  Procmail cannot compete with that.

It's . . . an illusory simplicity, I suspect.  But that's okay; it's something
everyone has to learn once in a while.  :)  Procmail has some real advantages,
of course, but it's true that you don't *need* it to do what you want to do.

| I notice that all software tends to bloat over time.

Well, accusing procmail of bloat is . . . perhaps a bit unfounded.  It's a
pretty specialized piece of software, and it hasn't tried to become a Swiss
Army Knife type of program.

| When I see a Web site that has a search engine just to search the FAQs, I
| know that there is a problem.

Yeah, but the problem might just be one's definition of "Frequently."  :)

| It's actually much easier for me to write something and install it than it
| would be to spends days or weeks trying to install someone else's bloated
| software.

Uh . . .

# cd /usr/ports/mail/procmail
# make install

Significantly less than "days."  Last time I checked, anyway.  Maybe you're
running on a 33MHz '486, though.  :)

| I'm sure something like Procmail has its place for enormously complicated
| situations that require enormously complicated solutions, but what I want to
| do is not in that category.

Actually, Procmail is useful in a wide variety of situations that require speed
and flexibility.  I use it extensively to dump my mail into separate folders
for me, to pipe some mail through scripts, to automatically reject others.  The
nice thing is that's it's all in one configuration file (.procmailrc), and
there's just not a lot else to worry about.

Seriously, you might want to look into this solution a little more before
giving up on it; it's a well-tested tool, and widely used.  And it's not as
hard as you might think.

| Incidentally, I've managed to get my script to drop HTML from messages
| generated by Outlook Express.  Now I'm just trying to handle the more general
| case of messages that are entirely in HTML: I want to change the HTML to
| plain text and then delete all the tags, leaving only whatever essential text
| remains.

http://search.cpan.org/author/RGARCIA/PerlIO-via-StripHTML-0.04/lib/PerlIO/via/StripHTML.pm


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: Getting Perl scripts to work as mail filters

2002-12-18 Thread Ken McGlothlen
"Mxsmanic" <[EMAIL PROTECTED]> writes:

| What about appending directly to the mailbox file under /var/mail/$USER with
| the script?

I'd recommend against that.  Using the sendmail interface is just as easy
programmatically as appending it to /var/mail/whatever, plus you don't run into
any messy issues with lockfiles and such.  Just use sendmail; it's already
there.

| Procmail is exactly the sort of bloated tool that I'm trying to avoid.

Well, for this, you don't need procmail, especially if you have a dedicated
alias for this.

| I don't know that calling sendmail again would be _that_ hard.  After all,
| I'm mostly just copying the input to the output.  I guess all I'd have to do
| would be to change the recipient address to avoid a loop (?).  Right?  Can't
| I just leave all the headers intact otherwise?

Absolutely; in fact, that's the best solution to the problem.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: Getting Perl scripts to work as mail filters

2002-12-18 Thread Ken McGlothlen
"Mxsmanic" <[EMAIL PROTECTED]> writes:

| What do I have to do to make a simple Perl script filter incoming mail for a
| mailbox?  I wrote a script that just reads standard input and writes it to
| standard output, then put it in my home directory, then changes
| /etc/mail/aliases to point to it, like this:
| 
| mymail:"|/usr/home/mymail/perlfilter"

I know that seems like the way it should work . . . but it's not.  What that
does is just pipe the message to your script---and at that point, sendmail is
done.  The output from your script went into the bit bucket.

What you're going to have to do is open up a sendmail process.  You can do
something like this in your Perl script, though:

open( MAIL, "| /usr/sbin/sendmail" );
print MAIL $headers;
print MAIL $body;
close MAIL;

Your headers will have to have all the relevant information, and be separated
from the body with a blank line.

Good luck with that.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: hosting more than one website on a cable connection (DHCP)... and using BIND

2002-12-13 Thread Ken McGlothlen
Bsd Neophyte <[EMAIL PROTECTED]> writes:

| I have a cable connection that uses DHCP, giving me a lease for about 2
| minutes.  Usually the address stays the same, but at times it does change.
| 
| I want to host two domain names to start.  I also would like to have the
| possiblity to host more.  I will have only one changing IP.

Well, okay.  The trick (as you already know) is to have whatever is hosting
your DNS entries to automatically update.  You'll want to investigate at

http://www.dyndns.org/

to see which services are right for you.  This is probably the easiest way to
handle dynamic IP DNS.

| I also want to have subdomains.  I want each system at home to have a
| subdomain based on either one of the two domain's I'll have established.  So
| if I have blah.com as my primary domain, I want to be able to ssh to
| yadda.blah.com from any other location.  If I want to ssh to yawn.blah.com
| from any other location, it should be able to connect to that system,
| eventhough they are both sharing 1 ip address through Natting.

Uh . . . okay.

That's . . . trickier.

Having subdomains for your webservices is easily done.  You can set up virtual
webservers in Apache all day on the same box, and go nuts with it.  The reason
it works is because they're all sitting at the same port on the same machine,
and Apache is sensitive to what domain name was used to access it.  ssh, on the
other hand, isn't.  If yadda and yawn are separate machines, and they're
sitting behind a firewall, and you want to get to them via SSH, you're going to
have to have separate ports on the firewall which will redirect to port 22 on
the target boxes.  Make sense?

| I've been told I can use these free third party domain name servers.  I've
| also been told that you need to keep a record with at least 2 domain name
| servers when hosting a domain name.

I suspect that dyndns.org has backup DNS already.  :)  In general, though,
having a DNS server behind a dynamic IP is . . . pointless.  Having an internal
DNS for your own firewalled network makes perfect sense, but you can't expect
to have the outside world use it.

| Now, I'm completely confused if this can be done and if it can, then how
| to do it.

This can be done.  How . . . well, start with dyndns.org; you'll have to handle
that bit first.  The rest is just ipfw/natd (or ipfilter/ipnat), Apache, and a
few other tidbits.

| The FreeBSD handbook seems pretty straight-forward in setting up BIND. 
| However, I don't know how to distinguish more than one domain name when
| using only one IP address.

Separate zone files.  One might be

$TTL 1D
@   IN  SOA dnsi.blah.com. hostmaster.blah.com (
2002120501  ; serial
8H  ; 2ndary chk
2H  ; retry
1W  ; discard
1W  ; RR TTL
)
A   192.168.0.2
MX  10 mx.blah.com.
MX  20 mx.offsitebackupmx.com.
mx  A   192.168.0.2
yadda   A   192.168.0.2
yawnA   192.168.0.2
www CNAME   yadda
dnsiCNAME   yawn

and another would be

$TTL 1D
@   IN  SOA dnsi.feh.com. hostmaster.feh.com (
2002120501  ; serial
8H  ; 2ndary chk
2H  ; retry
1W  ; discard
1W  ; RR TTL
)
A   192.168.0.2
MX  10 mx.feh.com.
MX  20 mx.offsitebackupmx.com.
mx  A   192.168.0.2
scratch A   192.168.0.2
belch   A   192.168.0.2
www CNAME   scratch
dnsiCNAME   belch

All the names just point to the same place in this case.

| Also, is it possible for the home DNS and the third party DNS's to work in
| tandem?

Probably not in the way you're expecting.  With dynamic DNS, you're pretty much
going to be dependent on external services for others trying to reach your
site.  When you get a static IP, you can pretty much do whatever you need.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: Returned message

2002-10-25 Thread Ken McGlothlen
Paolo <[EMAIL PROTECTED]> writes:

| About changing ISP, it's very difficult in Italy because interbusiness is the
| Internet provider of Telecom Italia, that's the last mile actual monopolist
| and, to get ADSL connection, we all need to deal with it.
| 
| Let's say you are excluding near 50% of italian on-line people. I don't know
| if it's fair.

Unfortunately, there seems to be little other recourse for getting
interbusiness to become a responsible participant in the Internet.  When enough
of its customers start getting upset because interbusiness finds itself on an
increasingly shrinking intranet, they might actually implement and enforce some
policies that would stop the onslaught of spam, and people would start taking
them out of their blocklists.

So let interbusiness know how you feel.  Make sure other interbusiness
customers let them know as well.  Pressure them on this.  Believe me, there's
nothing I'd like better than to remove their entry from my blocklists---I'd far
rather be dealing with a responsible ISP than have to block spam from them.

| As my 90% of spam is coming from the USA, I should block all the USA mail,
| don't I?

Wow.  Really?  90% of my spam comes from South Korea; they may be US crooks
sending the spam, but it's getting routed through insecure South Korean
servers.  Maybe that's the spammer credo:  only spam through other countries.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: I need some help...

2002-09-27 Thread Ken McGlothlen

"C T" <[EMAIL PROTECTED]> writes:

| [...] I am in the process of forming a non-profit organization that takes old
| computers (286's etc...), setting them up for email, word processing,
| internet browsing, spread sheets, and them giving them to people who can't
| afford computers.
| 
| One of my obstacles is finding an OS package similar to MS-DOS, but doesn't
| cost money.
| 
| Does FreeBSD distribute something simple that would operate on older
| machines?

Nothing that works on '286s---only '386s and later.

You might be better off working with something that more closely emulates
MS-DOS.  Check this out.

http://www.freedos.org/

And good luck.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: rmuser

2002-09-17 Thread Ken McGlothlen

"John Bolster" <[EMAIL PROTECTED]> writes:

| After I was done the user's home directory was gone and the name was gone
| from the system but now there are files that belong to "1002" (which was this
| user's number) that show up in repquota. I don't know how to find these files
| or why they weren't deleted. Any ideas?

$ find / -group 1002 -print


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



scp and non-shell accounts.

2002-07-17 Thread Ken McGlothlen

I have one system where my users have shell accounts and hang out on.  This has
an Apache server installed as a staging server.  I have another system which is
the production webserver.

I want my users to be able to transfer files to the production webserver using
scp or sftp, but not to have shell access on the production webserver.

So on the production machine, each of these users has a home directory, and a
shell of /sbin/nologin.

The problem is, this seems to trounce scp and sftp.  I get

wibble@staging:~(1)$ scp transfer.txt wibble@prod:~
wibble@prod's password: [type password]

This account is currently not available. [from /sbin/nologin]
wibble@staging:~(2)$ sftp prod
Connecting to prod...
wibble@prod's password: [type password]
Received message too long 173237622
wibble@staging:~(3)$ _

Do I really have to permit shell access for these accounts in order to use scp
or sftp?


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message