Help with my first email perl script

S

sanju.shah

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 address removed)' ); # use the sender's address here
$smtp->to('(e-mail address removed)'); # recipient's address
$smtp->data(); # Start the mail

# Send the header.
$smtp->datasend("To: (e-mail address removed)\n");
$smtp->datasend("From: (e-mail address 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
 
P

Paul Lalli

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top