I'm tyring to write something that will send a simple email using Perl
so far this is what I have -
#!/usr/bin/perl -w
-
use strict;
-
-
my $executable = "saplotus.exe';
-
my $server = 'test@domain';
-
my $from = 'aetinti@gmail.com';
-
my $to = 'aetinti@gmail.com';
-
my $subject = 'Test: Perl system call';
-
my $body = "Test: Perl system call";
-
-
my @args = ( "$executable", "-server", "$server",
-
"-from", "$from",
-
"-to", "$to",
-
"-subject", "\"$subject\"",
-
"-body", "\"$body\""
-
);
-
my $result = system(@args);
-
print "$result";
-
I also have the following but as I now understand I can't use this unless in Unix -
#!/usr/bin/perl
-
use CGI;
-
-
my $query = new CGI;
-
my $sendmail = "/usr/sbin/sendmail -t";
-
my $reply_to = "Reply-to: aetinti@gmail.com";
-
my $subject = "Subject: Confirmation of your submission";
-
my $content = "Thanks for your submission.";
-
my $to = $query -> param('send_to');
-
my $file = "subscribers.txt";
-
-
unless ($to) {
-
print $query->header;
-
print "Please fill in your email and try again";
-
}
-
-
open (FILE, ">>$file") or die "Cannot open $file: $!";
-
print $to,"\n";
-
close(FILE);
-
-
my $send_to = "To: ". $query->param('send_to');
-
-
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
-
print SENDMAIL $reply_to;
-
print SENDMAIL $subject;
-
print SENDMAIL $to;
-
print SENDMAIL "Content-type: text/plain\n\n";
-
print SENDMAIL $content;
-
close(SENDMAIL);
-
-
print $query->header;
-
print "Confirmation of your submission will be emailed to you.";
-
I know there's a way to get sendmail to work with windows I just haven't been able to figure it out ... can someone help me fix this script or offer on that will work? thank you
6 10520
Use this... -
#!C:\Perl\bin\perl.exe
-
-
use Net::SMTP;
-
-
my $relay='name-of-your-smtp-mailserver-here';
-
my $to='whoever@wherever.org';
-
my $from='you@yourdomain.org';
-
my $file='your_file.html';
-
-
open(FILE,"$file");
-
@body=<FILE>;
-
-
my $smtp = Net::SMTP->new($relay) || die "Did Not Connect\n" if !($smtp);
-
-
$smtp->mail($from); # use the sender's address here
-
$smtp->to($to); # recipient's address
-
$smtp->data(); # Start the mail
-
-
# Send the header.
-
$smtp->datasend("To: $to\n");
-
$smtp->datasend("From: $from\n");
-
$smtp->datasend("Content-type: text/html\n\n");
-
-
# Send the body.
-
$smtp->datasend(@body);
-
$smtp->dataend(); # Finish sending the mail
-
$smtp->quit; # Close the SMTP connection
-
Thanks, it's not connecting but it compiles :) one battle down one to do ... I may not be able to connect to google this way anymore which may be the problem. Thanks Again for all you help
BobVDP,
Thanks for your post it was a real help for me! I got the script to connect by using the SMTP server IP addres, not the server name.
Thanks,
Merv
Atinti and BobVDP,
You really need to please use code tags whenever you post code in the forums. They are required and are mentioned in the Posting Guidelines, which you should have already read. If not, please do so.
If you don't add them, us Moderators need to clean up behind you and we really prefer you add them when you post.
Thank you!
Regards,
Jeff
(Perl Forum Leader)
The OP made this post over a year ago. I am willing to bet they may not get the warning message.
--Kevin
(peon moderator) :)
The OP made this post over a year ago. I am willing to bet they may not get the warning message.
--Kevin
(peon moderator) :)
You know, I (again) didn't think to look at the dates. You would think that I would learn.
Merv: You need to respond to newer posts. Not that the older posts don't deserve an answer, but if they haven't posted regarding the issue in that long then they either fixed the issue or don't care.
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sven Templin |
last post by:
Hello all,
our configuration is as following described:
- OS: Windows 2000
- Apache server 1.3
- Php 3.8
- MS outlook client 2000
_and_ no SMTP server available in the whole intranet.
|
by: dpackwood |
last post by:
Hello,
I have two different scripts that do pretty much the same thing. The main
perl script is on Windows. It runs and in the middle of it, it then calls
out another perl script that then...
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: Carl |
last post by:
Hi,
Using MS Access 2000, is it possible to run a UPDATE or INSERT SQL query
using some form
of conditional IF THEN ??
for example:
SELECT * FROM Books
IF EXISTS(Select Books.ID = 1)
|
by: Doomster |
last post by:
In a previous job, we had Perl scripts which could interact with a SQL
DB using Perl's DBI module We were able to programmatically add,
delete and query tables using this module.
Is it possible...
|
by: krash88 |
last post by:
I'm as new as it gets to PERL and have been going over a few scripts for an NT server that I run. One of which sends an email to registered users using SMTP.
It seems to connect with SMTP server...
|
by: ibid |
last post by:
hi every one just wondering if anyone could help sorry if i seem abit dumb but im a newbie to it all
ive got to asign a mail program on my auction site in the config.pl files (i think this is the...
|
by: Ant |
last post by:
Hello!
I am looking for a good hardcopy Perl book for newbies/beginners
(including myself) who use Windows (not UNIX/Linux) and that isn't so
old. After talking to my Linux friends who use Perl,...
|
by: happyse27 |
last post by:
Hi All,
I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |