Perl script for sending mail trough Gmail 
June 19th, 2008Category: My Life
Nothing fancy, just a few prompts and use of Net::SMTP::SSL and Authen::SASL
#!/usr/bin/perl -w# Send email from Gmail# Will not work on windows, because of the echo# for the password. Just uncomment the two# system lines and should be fine.# Will wait for EOF (Ctrl+D) for the msg body.# by GTuse Net::SMTP::SSL;my $smtp;my $username = 'youremail@gmail.com';my $password;my @lines;my $msg = "";my $to;my $subject;$smtp = Net::SMTP::SSL->new('smtp.gmail.com', Port => 465, Debug=>1) || die "Cannot connect to server" ;system('stty -echo');print "Enter password:";$password = <STDIN>;chomp $password;system('stty echo');$smtp->auth($username, $password) || die "Authentication failed";print "\nTo:";$to = <STDIN>;chomp $to;print "Enter subject:";$subject = <STDIN>;chomp $subject;print "Enter message:\n";@lines = <>;foreach $line (@lines){$msg = $msg.$line;}$smtp->mail($username."\n");$smtp->to($to."\n");$smtp->data();$smtp->datasend("From: ". $username."\n");$smtp->datasend("To: ".$to."\n");$smtp->datasend("Subject: ".$subject."\n");$smtp->datasend("\n");$smtp->datasend($msg."\n");$smtp->dataend();$smtp->quit;- Свалете този код/download this code: gmailsmtp.pl
Leave a Reply
Georgi’s Blog is proudly powered by
WordPress
Постове (RSS)
and Коментари (RSS).

22 queries. 0.814 seconds.

