Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problme to send a mail 1

Status
Not open for further replies.

donny750

Programmer
Jul 13, 2006
145
FR
hello,

I've use this perl script

Code:
#!/usr/bin/perl

unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me\@mydom.com\n";
print MAIL "To: address\@mailserver.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "test mail message";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";
}

but i've not received the mails
i don't understand why ?
Can you help me ?

Thanks
 
there is nothing wrong with your code per-se. Try like this:

Code:
open (MAIL, "|/usr/sbin/sendmail") or die "Error starting sendmail: $!";
print MAIL "From: me\@mydom.com\n";
print MAIL "To: address\@mailserver.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "test mail message";
close(MAIL) or die "Error closing mail: $!";
print "Mail sent.\n";


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
This is hosted on a *nix server?
Have you looked at some of the Perl mail modules on
Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I've tried out your code and it worked fine for me as-is.

I'd start by investigating the mail logs to make sure there isn't a non-perl related issue at work here. Also double-check that the path to your sendmail binary is correct.

Hope this helps.
 
donny750 said:
but i've not received the mails
No, but you will. Don't post your real unobfuscated email address on a forum like this unless you really like spam... [wink]

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
I know this seems obvious, but i want to mention it just in case that's it...
I had to struggle with this problem for a few days, just to find out that the problem was spam filters.

Some mail services require a certain set of headers, including what user-agent was used and other redundancy, using a module solves this, but your message still might end up in the spam folder (where i found mine, after a few days [noevil])
 
very valid point, have a * ;-)

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top