Hi ,
I am trying to send mail from unix perl.
I am using following code to send mail.
It is not triggering mail and also it is not giving any error.
please tell me any special settings are required or this program should be executed from special user with higher permission or something.
please tell me.
what changes i should bring into this program so that this program should work fine. - #!/usr/perl/bin/perl
-
print "Content-type: text/html\n\n";
-
-
$title='Perl Mail demo';
-
$to='shafi.mohammed@expt.com';
-
$from= 'helpdesk.in@expt.com';
-
$subject='YOUR SUBJECT';
-
-
open(MAIL, "|/usr/sbin/sendmail -t") || die "unable to open";
-
print "hhhh ",<MAIL>,"\n";
-
-
## Mail Header
-
print MAIL "To: $to\n";
-
print MAIL "From: $from\n";
-
print MAIL "Subject: $subject\n\n";
-
## Mail Body
-
print MAIL "This is a test message from Cyberciti.biz! You can write your mail body text here\n";
-
-
close(MAIL);
shafi
4 4249
The really only thing I see missing is the header for the email itself. - print MAIL "Content-type:text/plain; charset=iso-8859-1\n";
Here is a sample of one I did playing around with the some time ago. - #! /usr/bin/perl
-
-
use strict;
-
use warnings;
-
-
use CGI;
-
use CGI::Carp qw/fatalsToBrowser/;
-
-
my $q = CGI->new;
-
-
print $q->header;
-
print $q->start_html(-title =>'Mysite.com');
-
-
my $mail_path = '/usr/sbin/sendmail -i -t';
-
my $email_to = 'xxx@xxx.com';
-
my $email_from = 'xxx@xxx.com';
-
my $email_subject = 'Testing My Email';
-
my $email_message = qq~
-
<pre>Hello $email_to,<br><br>
-
-
Thank you for $email_subject service.<br>
-
<a href="http://www.somesite.com">Some Site</a></pre>
-
~;
-
-
&send_email($email_to, $email_from, $email_subject, $email_message);
-
-
sub send_email{
-
-
my ($to, $from, $subject, $message) = @_;
-
-
open (my $MAIL, "|$mail_path") || print "Could Not Open Mail Program!";
-
-
print $MAIL "Content-type:text/html; charset=iso-8859-1\n";
-
print $MAIL "To: $to\n";
-
print $MAIL "From: $from\n";
-
print $MAIL "Subject: $subject\n\n";
-
print $MAIL "$message\n\n";
-
-
close ($MAIL);
-
-
print 'Done. Please check your email box';
-
-
}
-
print $q->end_html();
-
-
1;
Hopefully it will help you! Also, please be sure to use the [CODE][/CODE] tags when posting code here. Thank you!
--Kevin
Hello here is the sample code with all the parameter filled still it is not working please let me know. - #!/opt/perl/bin/perl -w
-
-
my $send_to = "To: ".'shafi.mohammed@capgemini.com'."\n";
-
-
my $subject="hi";
-
my $content="how r u";
-
-
my $from='sandip.swain@capgemini.com';
-
my $sendmail = "/usr/sbin/sendmail -t";
-
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
-
print SENDMAIL "Content-type:text/plain; charset=iso-8859-1\n";
-
print SENDMAIL $subject;
-
print SENDMAIL "From: $from\n";
-
print SENDMAIL $send_to;
-
print SENDMAIL "Content-type: text/plain\n\n";
-
print SENDMAIL $content;
-
close(SENDMAIL);
-
-
print "\nProcess completed\n";
Have you configure the ip address in the sendmail module...
try to run the sendmail command from unix prompt, then you will have some understanding on where exactly the problem lies, ie., unix config, or calling from perl
also you can try using mailx utility in Unix
-Nagendra
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: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# Suppose you want to spam your friend, and you have lots of
# friends. The solution is to write a program to do it. After a gander
# at python docs, one easily...
|
by: Leo Breebaart |
last post by:
I am writing a utility in Python and I'd like to add a
command-line option "--mailto <address>" that will cause an
e-mail summary to be sent to <address> when the utility finishes
running.
My...
|
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: Kevin J Wholley |
last post by:
How do I write a perl program to send mail from an xp box?
specifically, I am writing a clearcase trigger that sends mail
on a checkout. This functions perfectly from unix but I also
need it to...
|
by: Michael |
last post by:
I know that in order to send an e-mail using Perl there must be a '\'
in front of the '@' symbol. For example department\@company.com. And
it works.
The problem that I am having is that we have...
|
by: tuspa |
last post by:
Hi,
I work on modelslim installed on unix server.It has its own prompt called vsim prompt.By using perl script,i call the vsim prompt ,I run what i want and then its stays in vsim promp.so,my...
|
by: cnsabar |
last post by:
Hi.,
I am using following code to send sms through e-mail
use Mail::Sendmail;
%mail = (To => '10digitMobileNo@airtelkk.com',
From => "mymail\@company.com",
Message =>...
|
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: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |