Hi,
I'm having trouble getting the right "From: " in emails sent using sendmail. If I define my $sender as an email address, it works fine, but when I try to read the email in as a parameter from a form, when the mail is delivered, it appears as: "emailaddress@domain.com"@myservername
How can I stop it from putting it in quotes and attaching the server name?
(I'm not sure if the problem is coming from the sendmail part or the parameter reading part, so I put in both).
Parameter reading:
use CGI qw(:standard);
@paramater=param();
$numberofparamaters=@paramater;
$i=0;
while ($i<$numberofparamaters)
{
@data[$i] = param(@paramater[$i]);
if (@paramater[$i] =~ /email/)
{
$sender=@data[$i];
}
$i++;
}
$sender =~ s/@/\\@/;
Sendmail:
my ($to, $from, $subject, $message) = @_;
my $sendmail = '/usr/sbin/sendmail';
open(MAIL, "|$sendmail");
print MAIL "From: $sender\n";
print MAIL "To: ???\@gmail.com\n";
print MAIL "Subject: Amapro signup\n\n";
$i=0;
while ($i<$numberofparamaters)
{
print MAIL "@paramater[$i]";
print MAIL ": ";
@data[$i] = param(@paramater[$i]);
print MAIL @data[$i];
print MAIL "\n";
$i++;
}
close(MAIL);