The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rsh permission denied lweegp Shell Programming and Scripting 7 09-15-2006 01:36 AM
Permission Denied howeezy UNIX for Dummies Questions & Answers 0 09-14-2005 06:52 AM
./ Permission Denied. trouscaillon UNIX for Dummies Questions & Answers 8 01-26-2005 06:33 PM
rcp 'permission denied' Kevin Pryke UNIX for Dummies Questions & Answers 6 04-24-2002 01:20 AM
rsh and permission denied Reza Nazarian UNIX for Dummies Questions & Answers 1 10-15-2001 09:21 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-30-2008
LNC LNC is offline
Registered User
 

Join Date: Dec 2007
Posts: 9
Perl: Sendmail - Permission denied

Hi,

I'm trying to write a simple mail handler perl script for a website I'm working on. I've managed to installed sendmail yesterday, and I'm currently trying to get the script to work. I'm getting an error however.

Here's the block of perl code I'm using:

Code:
open(MAIL, "| $sendmailpath -t") || print "Error Opening mail: $!";
print MAIL "To: my\@e-mail.com";
print MAIL "Reply: $sender_mail";
print MAIL "Subject: $sender_subj";
print MAIL "\n";
print MAIL "$sender_msg";
close MAIL || print "Error Closing mail: $!";
The error I'm getting is "Error Opening Mail: Permission Denied". I'm not trying to run a mailserver or anything, I just want to send email from a webpage.

I'm assuming it's a user/group/permission problem, since the sendmail program is being run by the webscript. However, this is my first time working with sendmail, and I have no idea what the correct settings should be.
Reply With Quote
Forum Sponsor
  #2  
Old 04-30-2008
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Hi,
Chance is you might already have this package Net::SMTP - perldoc.perl.org try it, its the same as yours but avoid invoking sendmail binary directly IMHO. Anyway you can download it on Net::SMTP - Simple Mail Transfer Protocol Client - search.cpan.org
Reply With Quote
  #3  
Old 04-30-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
So what's in $sendmailpath?
Reply With Quote
  #4  
Old 04-30-2008
LNC LNC is offline
Registered User
 

Join Date: Dec 2007
Posts: 9
The $sendmailpath contains /usr/sbin/sendmail.

When using Net::SMTP I need to connect to an SMTP server though correct? I'm trying to avoid this here.
Reply With Quote
  #5  
Old 04-30-2008
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Quote:
Originally Posted by LNC View Post
The $sendmailpath contains /usr/sbin/sendmail.

When using Net::SMTP I need to connect to an SMTP server though correct? I'm trying to avoid this here.
Thats correct, but /usr/sbin/sendmail will talk to a SMTP server as well unless the recipient is on your localhost. And if its on another host then you defenitly need to speak to a smtp server, your mail gateway, (either with /usr/bin/sendmail or any other client Net::SMTP) that will deliver that mail to the recipient...
Reply With Quote
  #6  
Old 04-30-2008
LNC LNC is offline
Registered User
 

Join Date: Dec 2007
Posts: 9
Alright, perhaps I should try to send it through my ISP's smtp server. I'm running this webform on my own home system. But, don't I have to enter a login and password for the smtp server? how would I do that with Net::SMTP?
Reply With Quote
  #7  
Old 04-30-2008
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Nope, you're not required to use authentication to send mail only retreiving would ... and you even wont need you're ISP mail gateway.
Here's a sample code:
Code:
#!/usr/bin/perl -w

use Net::SMTP;

$smtp = Net::SMTP->new("recipent.server.com",Hello => 'yourdomain.com');
$smtp->mail("fromyou@yourdomain.com");
$smtp->to("user1@server.com");
$smtp->cc("foo@server.com");
$smtp->data;

$smtp->datasend("From: fromyou\@yourdomain.com");
$smtp->datasend("To: user1\@server.com");
$smtp->datasend("Subject: This is a test");
$smtp->datasend("\n");

$smtp->datasend("Body Of The Mail");

$smtp->dataend;
$smtp->quit;
Hope that helps! Assuming the host you're sending mail from is connect on the net ...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
sendmail

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0