Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help with my first email perl script

Reply
Thread Tools

Help with my first email perl script

 
 
sanju.shah@gmail.com
Guest
Posts: n/a
 
      07-11-2005
After going thru the Active Perl documentation, I am playing with a
test email script. 2 issues i am facing:

1. When i get the email - the from & to address does not contain the
@company - it is only 'shah.com'
2. How do i attach attachments?

TIA,

Regards,
Sanju

Script:

use Net::SMTP;

$smtp = Net::SMTP->new('mailserver.company.com'); # connect to an SMTP
server
$smtp->mail( '(E-Mail Removed)' ); # use the sender's address here
$smtp->to('(E-Mail Removed)'); # recipient's address
$smtp->data(); # Start the mail

# Send the header.
$smtp->datasend("To: http://www.velocityreviews.com/forums/(E-Mail Removed)\n");
$smtp->datasend("From: (E-Mail Removed)\n");
$smtp->datasend("\n");

# Send the body.
$smtp->datasend("Hello, World!\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      07-11-2005
(E-Mail Removed) wrote:
> After going thru the Active Perl documentation, I am playing with a
> test email script. 2 issues i am facing:
>
> 1. When i get the email - the from & to address does not contain the
> @company - it is only 'shah.com'


You have failed to 'use strict;' and 'use warnings;'. Either of these
statements would have told you what caused this error.

Have you read the posting guidelines for this newsgroup? They contain
helpful hints like that which tell you how you can best help yourself,
and how to best help us help you.

> 2. How do i attach attachments?


The docs for Net::SMTP specify that this module is for those who are
familiar with the SMTP RFC. If you are not, you would be better off
using a higher-level mailing module, which provides interfaces for
things such as attachments. You could search CPAN for such a module
(perhaps Mail::Mailer or Mail::Internet might help?) or you could (and
should have) checked the Perl FAQ:
perldoc -q attachment

<code remains below for reference>

Paul Lalli

>
> use Net::SMTP;
>
> $smtp = Net::SMTP->new('mailserver.company.com'); # connect to an SMTP
> server
> $smtp->mail( '(E-Mail Removed)' ); # use the sender's address here
> $smtp->to('(E-Mail Removed)'); # recipient's address
> $smtp->data(); # Start the mail
>
> # Send the header.
> $smtp->datasend("To: (E-Mail Removed)\n");
> $smtp->datasend("From: (E-Mail Removed)\n");
> $smtp->datasend("\n");
>
> # Send the body.
> $smtp->datasend("Hello, World!\n");
> $smtp->dataend(); # Finish sending the mail
> $smtp->quit; # Close the SMTP connection


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI: Execute a perl script inside another perl script xdarcos@hotmail.com Perl Misc 20 01-18-2005 12:33 PM
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments