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 4263 eWish 971
Recognized Expert Contributor
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 found the module for the job.
# see http://python.org/doc/2.3.4/lib/SMTP-example.html
# the code is a bit long with the command line, but the key lies at
# the bottom four lines. The gist is this:
|
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 first thought was to use smtplib.sendmail(), and basically
this works like a charm, except that this function expects a
valid 'sender' address as a parameter.
Every single smtplib example I've found so far shows a hardcoded
|
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 should run on a Unix box I have. Both
scripts run ok, except for the part when Windows try's to call out the
Unix script. I have it set up where the Unix is mapped through a drive
letter and can drop stuff into the Unix box. It is going through another...
|
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 run from xp for my clearcase users that use the
clearcase client on the desk top
| |
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 many customers whom we
need to direct towards their own personal online order form. For some
reason when I try to place the '\' in front of the '@' symbol it does
not work.
For example person@isp.com. In order to send them an e-mail we need to
|
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 question is how to switch to unix prompt from vsim prompt.
the following is the code:
#!/usr/intel/bin/perl
$vlog = "vlog *.v < tt.txt";
print "$vlog";
open (PINGTEST, "vsim rwr0unit -f tcl_script -c |");
|
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 => "SMS Server"
);
|
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 is working for normal email servers, but NOT with gmail server, I am very puzzled still!!)
Codes(item c below) It keeps complaining and logs and codes are below.
a) apache access logs
---------------------------------
127.0.0.1 - - "GET...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |