CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Using Mail, From



Apr 5, 2000, 10:13 PM

Post #1 of 2 (1735 views)
Using Mail, From Can't Post

I'm trying to modify a CGI/perl script for one of our webservers.

The simple script.cgi takes a comment from a form, writes the information to a file and then sends a letter to the originator to conform that the info was received.

The end result is an email with the From: looking like an email address, which it's not.
(Any spaces in the From: are changed to periods)
There isn't any email on the system except for the sendmail that goes out and I would rather not set any up.

Is there anyway that I can still use the From field, but keep it from qualifying the name?

This is what I have in that subroutine:
foreach (@mail_user) {
open(MAIL, "| mail $_");

print MAIL "Subject: Comments/Suggestions\n";
print MAIL "From: Our Web Server\n";

$fields{'comment_line'} =~ s/%0D%0A/\n/g;

print MAIL $fields{'comment_line'}."\n\n";
print MAIL "Name: $fields{'name'}\n";
print MAIL "E-mail: $fields{'email'}\n";
print MAIL "Phone: $fields{'phone'}\n";
close (MAIL);

The end result of this email would have the From field like:


Administrator / Moderator

Apr 6, 2000, 3:56 PM

Post #2 of 2 (1735 views)
Re: Using Mail, From [In reply to] Can't Post

That's happening because the From is supposed to be from an email address. If you want to use a name in conjunction with an email address, enclose the from name in parenthesis, like this:

print MAIL "From: $email($name)\n";

If you don't want to include an email address whatsoever, try leaving the From blank. Depending on your server, that may or may not work (some servers won't allow the sending of "anonymous" email).

Good luck!


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives