Re: [expert] mail from CGI scripts

2000-11-01 Thread Daniel Woods


> I have a system that generates PDFs, and I want to mail them back the
> user (whose name I have access to in the script). Currently I am just
> sending a mail to them with a link to the location of the file. 
> 
> Does anybody know how I would accomlish this ? I have messed around with
> the mailto command, and I think I even got it to send a PDF when in
> interactive mode, but that will not do.
> 
> I also tried :
> $ echo "Your PDF is ready\n~*\n ..etc" | mailto  -s ''
> 
> Anyone know how to do this ?
> 
> Regards,
> Buchan

sendmail / postfix / qmail are mail transfer agents (MTA).
You need a mail user agent (MUA) like pine, mutt, netscape, etc. 
Otherwise you need to talk directly to the smtp port.
Write a perl script using the MIME::Lite package.

To see if you have MIME::Lite, see what happens with...
~--> perldoc -l MIME::Litt
No documentation found for "MIME::Litt".
~--> perldoc -l MIME::Lite
/usr/lib/perl5/site_perl/5.6.0/MIME/Lite.pm

To get that Perl module, add this
alias cpan='perl -MCPAN -e shell'
to your ~/.bashrc file (and do: . ~/.bashrc). Now type 'cpan',
and at the cpan > prompt, enter
install MIME::Lite
If this is the first time, you will have to configure Bundle::CPAN

Here's a test example...

###
#! /usr/bin/perl -w
#
#  mail_smtp.pl

use MIME::Lite;

# MIME::Lite->quiet();
# MIME::Lite->send('sendmail', '/usr/lib/sendmail -t -oi -oem');  #default
MIME::Lite->send('smtp', 'smtp.myisp.com', Timeout=>60);

# Create a new multipart message:
$msg = new MIME::Lite
From=>'[EMAIL PROTECTED]',
To  =>'"Dan Woods" <[EMAIL PROTECTED]>',
Subject =>'multipart testing',
'X-Mailer' =>'4loops.com 1.0',
Organization =>'4Loops Internet Services',
'Reply-To' =>'[EMAIL PROTECTED]',
Type=>'multipart/mixed';

$msg->attr("content-type.charset" => "iso-8859-1");

# Add parts (each "attach" has same arguments as "new"):
attach $msg
Type=>'TEXT',
Data=>"Here's the newest archive:";
attach $msg
#   Encoding =>'quoted-printable',
Type=>'text/plain',
Disposition =>'attachment',
Path=>'4loopsFiles.cgi';
attach $msg
Encoding =>'base64',
Type =>'image/gif',
Path =>'../public_html/popc.gif',
Filename =>'popc.gif';
attach $msg
Encoding =>'base64',
Type =>'application/pdf',
Path =>'../public_html/Downcoding.pdf',
ReadNow  => 0,
Filename =>'Downcoding.pdf';
# attach $msg
#   Encoding =>'base64',
# # Type =>'BINARY',
# # Type =>'application/octet-stream',
#   Type =>'application/msword',
#   Path =>'../public_html/Downcoding.doc',
#   ReadNow  => 0,
#   Filename =>'Downcoding.doc';

# Send the message:
# Send in the "best" way (the default is to use "sendmail"):
$msg->send || die "Mail not sent!";

# end of script mail_archive.pl
###

Thanks... Dan.





Keep in touch with http://mandrakeforum.com: 
Subscribe the "[EMAIL PROTECTED]" mailing list.



[expert] Mail from CGI scripts

2000-11-01 Thread Bob [EMAIL PROTECTED]

Thanks for everyone's input - I figured out how to get sendmail & mail to do the right 
thing.

However, my question becomes this: how can I configure my MDK 7.1 such that when a CGI 
script is executed from a given virtual host, it puts the virtual host's name on the 
"from: " domain?  I have customers from another service that is running an older 
version of Linux that seems to do this.  Is this an Apache thing?  I am running the 
1.3.12 Advanced Extranet.

Bob



Keep in touch with http://mandrakeforum.com: 
Subscribe the "[EMAIL PROTECTED]" mailing list.



Re: [expert] mail from CGI scripts

2000-11-01 Thread Buchan Milne

I have a system that generates PDFs, and I want to mail them back the
user (whose name I have access to in the script). Currently I am just
sending a mail to them with a link to the location of the file. 

Does anybody know how I would accomlish this ? I have messed around with
the mailto command, and I think I even got it to send a PDF when in
interactive mode, but that will not do.

I also tried :
$ echo "Your PDF is ready\n~*\n ..etc" | mailto  -s ''

Anyone know how to do this ?

Regards,
Buchan

Jim Holthaus wrote:
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> > What is the proper syntax to call sendmail (or mail) with to set the From: address?
> 
> - From man sendmail:
> 
>-f sender
>   Set  the  envelope  sender  address.  This  is  the
>   address where delivery problems are sent to, unless
>   the message contains an Errors-To: message  header.
> 
>-F full_name
>   Set the sender full name. This is  used  only  with
>   messages that have no From: message header.
> 
> If you want to do it all on the command line, try it like this:
> sendmail -f"[EMAIL PROTECTED]" -F"[EMAIL PROTECTED]" < messagefile
> 
> Note that this assumes your message doesn't have a from header already added to
> it (seems likely based on the situation you describe.

-- 
|--|
Buchan MilneMechanical Engineer, Network Manager
Cellphone   +27824722231
email   mailto:[EMAIL PROTECTED]
Centre for Automotive Engineering   http://www.cae.co.za
South Africas first satellite:http://sunsat.ee.sun.ac.za
Control Models  http://www.control.co.za
|Registered Linux User #182071-|



Keep in touch with http://mandrakeforum.com: 
Subscribe the "[EMAIL PROTECTED]" mailing list.



Re: [expert] mail from CGI scripts

2000-10-30 Thread Jim Holthaus

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> What is the proper syntax to call sendmail (or mail) with to set the From: address?

- From man sendmail:

   -f sender
  Set  the  envelope  sender  address.  This  is  the
  address where delivery problems are sent to, unless
  the message contains an Errors-To: message  header.   

   -F full_name
  Set the sender full name. This is  used  only  with
  messages that have no From: message header.

If you want to do it all on the command line, try it like this:   
sendmail -f"[EMAIL PROTECTED]" -F"[EMAIL PROTECTED]" < messagefile

Note that this assumes your message doesn't have a from header already added to
it (seems likely based on the situation you describe.
- -- 
Jim Holthaus   (pronunciation: HOLT house)
[EMAIL PROTECTED]
PGP Public Key at http://www.holthaus.com/jim/pgpkey.html
Learn about PGP at http://www.holthaus.com/jim/pgp.html

-BEGIN PGP SIGNATURE-
Version: PGP 6.5.1

iQA/AwUBOf3IOX3IcJJ+eC/CEQL+4wCgs2R3wzk4M4Q+lNzJP693pGbk3fcAoOFV
cOkVedK4GKfmoy3vkjMI3Vs3
=ykfB
-END PGP SIGNATURE-



Keep in touch with http://mandrakeforum.com: 
Subscribe the "[EMAIL PROTECTED]" mailing list.



[expert] mail from CGI scripts

2000-10-27 Thread Bob [EMAIL PROTECTED]

Hello,

I have a user that has a frequently-accessed CGI script that is like an auto-responder 
- simply sends a message to the mail address the user types in on this form.

The problem is that the From: part of the message says "[EMAIL PROTECTED]", of which 
nlenet.net is the name of the machine.  I want this to be customized to the customer's 
virtual host name, also to keep bogus requests from being mailed back to me (root).

What is the proper syntax to call sendmail (or mail) with to set the From: address?

Bob



Keep in touch with http://mandrakeforum.com: 
Subscribe the "[EMAIL PROTECTED]" mailing list.