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);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.