The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 04:36 AM
Permission Denied howeezy UNIX for Dummies Questions & Answers 0 09-14-2005 09:52 AM
./ Permission Denied. trouscaillon UNIX for Dummies Questions & Answers 8 01-26-2005 09:33 PM
rcp 'permission denied' Kevin Pryke UNIX for Dummies Questions & Answers 6 04-24-2002 04:20 AM
rsh and permission denied Reza Nazarian UNIX for Dummies Questions & Answers 1 10-15-2001 12:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
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.
  #2 (permalink)  
Old 04-30-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
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
  #3 (permalink)  
Old 04-30-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
So what's in $sendmailpath?
  #4 (permalink)  
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.
  #5 (permalink)  
Old 04-30-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
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...
  #6 (permalink)  
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?
  #7 (permalink)  
Old 04-30-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
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 ...
Closed Thread

Bookmarks

Tags
sendmail

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0