CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
smtp and image file

 



flat_brain
stranger

May 18, 2001, 3:27 PM

Post #1 of 3 (503 views)
smtp and image file Can't Post

I have two questions. First, I tried to fetch image file by http. Here is the code. The problem is, I don't think that, the image saved in right format (binary). I could not open it. How to solve it?

******************
require LWP::UserAgent;
require HTTP::Request;
$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => 'http://msimg.com/nipimage/AL_summer0518.jpg');
$response = $ua->request($request);
open(RESULTFILE, ">res.jpg");
if($response->is_success){
print RESULTFILE $response->content;
}else{
print $response->error_as_HTML;
}
close(RESULTFILE);
*******************

The second, I tried to use Net::SMTP to send mail. But the SMTP asks the password (I figured out by debugging the code, it failed to connect to server,
saying need password). How should I do? I think I need to use socket to get response from server then send it user/passwd, but how to do it. Better to get
sample code for this.

Thanks,

Hui Deng

*****************
use Net::SMTP;

$smtp = Net::SMTP->new('smtp.yahoo.com');

$smtp->mail($ENV{USER});
$smtp->to('postmaster');

$smtp->data();
$smtp->datasend("To: postmaster\n");
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend();

$smtp->quit;
*****************



wickedxter
User

May 18, 2001, 3:58 PM

Post #2 of 3 (499 views)
Re: smtp and image file [In reply to] Can't Post

try
binmode(<FILE_NAME>);

this should make it binary..



Cure
User

May 26, 2001, 10:29 PM

Post #3 of 3 (485 views)
Re: smtp and image file [In reply to] Can't Post

On win32 you have to use binmode().


Cure


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives