LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   howto send a mail with attachment via perl script ? (https://www.linuxquestions.org/questions/programming-9/howto-send-a-mail-with-attachment-via-perl-script-150129/)

cccc 03-05-2004 12:02 PM

thanks dford

I don't know, what's wrong.
I use the same script and it doesn't send any mails !
I've spend a lot of time about this problem.

greetings
cccc

dford 03-05-2004 12:39 PM

Is sendmail running? I tested sending through sendmail directly with this:
Code:

echo 'From: dford1234@metapath.com
To: dford1234@computer.org
Subject: Test
Hi!
Bye!
.' | /usr/sbin/sendmail dford1234@computer.org

Something like this should work. If it doesn't, perhaps you are running qmail or another MTA? Or no MTA at all?

Note: email addresses were altered to not add to my spam load. You can probably figure them out though. :D

cccc 03-05-2004 01:34 PM

Yes !

this one for example works excellent and sends mail:

Code:

open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "to:$mail\n";
print MAIL "from:$linux\n";
print MAIL "subject:sendmail test\n";
print MAIL "hi\n\n";
print MAIL "TEST\n\n";
close(MAIL);
}

I don't know if really important, but I use postfix
and the path to postfix is:
/usr/sbin/sendmail
I use this path at all other scripts and it works.

kind regards
cccc

dford 03-05-2004 02:39 PM

Hmmm...try something like this instead of the $msg->send(); line:
Code:

$str = $msg->as_string;
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL $str;
close(MAIL);

This should turn the message into a string and then print that string in the same way your working example does. You may need to tweak this some, but it should work. Again this works on my system, but my system is using a "traditional" sendmail.

cccc 03-05-2004 03:10 PM

I've replaced, but now I have on this new lines errors:

[Fri Mar 5 22:07:47 2004] mail.cgi: Global symbol "$str" requires explicit package name at mail.cgi line 58.
[Fri Mar 5 22:07:47 2004] mail.cgi: Global symbol "$str" requires explicit package name at mail.cgi line 60.
[Fri Mar 5 22:07:47 2004] mail.cgi: Execution of mail.cgi aborted due to compilation errors.

dford 03-05-2004 03:46 PM

You might just add:
my $str;

cccc 03-05-2004 03:59 PM

thanks for your time and help, but still no mails


dford 03-05-2004 07:19 PM

So, just to be clear, when you enter:
Code:

perl mail.cgi /var/log/log.txt
or something similar you get no error messages and no email? It just returns you to a prompt?

cccc 03-05-2004 07:47 PM

Hi

sorry, my mistake the file was not readable.
now it works !

thanks for your time and HELP !
cccc

dford 03-05-2004 07:49 PM

You are welcome! Glad it is working now!


All times are GMT -5. The time now is 10:01 PM.