Re: mail prob
| From: | Simon Garner | Date: | Fri, 23 Feb 2001 06:56:02 +0000 |
| Subject: | Re: mail prob | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41276@lists.php.net to get a copy of this message | ||
From: "W.D." <suedeuno@yahoo.com>
> yea I guess that would work better, I dunno tho, I tried setting $from =
> $Email and the blasted server still served it up as nobody in the header.
> But the rest would make more sense. Yes info@domain.com would need a copy
to
> trigger an autoresponse. I know I probably seem like someone who hasnt
read
> much php, but Ive actually read a couple php4books, the first an easier
> learning and the second PHP 4 Bible. I'm still a newbie tho so bare with
me.
>
Okay, it sounds like you're forgetting the "From: " prefix in front of
$from.
This prefix is necessary because the mail message you are composing must
come out looking essentially like this (this is what gets given to your SMTP
mail server):
To: webmaster@domain.com
From: me@myserver.com
Cc: info@domain.com
Subject: Blah
Here is the main body of the message.
Now, PHP's mail() function will automatically insert the To: and Subject:
headers, and the body, from the first three arguments to mail(). But to add
the custom From: and Cc: headers, you have to add them yourself (correctly
formatted as mail headers) using the fourth argument to mail().
Which is how we get to:
mail("webmaster@domain.com", $subject, $message,
"From: $from\nCc: info@domain.com");
Making sense? :)
>
>
> > From: "W.D." <suedeuno@yahoo.com>
> >
> > > <form method="POST" action="<?php print
> > > ($PHP_SELF);?>">
> > > First Name: <input type=TEXT name="FirstName" size=15><p>
> > > Last Name: <input type=TEXT name="LastName" size=25><p>
> > > E-mail Address: <input type=TEXT name="Email" size=25><p>
> > > <textarea name="Info" rows="5" cols="40"
> > > wrap=SOFT>Ask a
> > > Question</textarea><p>
> > > <input type=SUBMIT> <input type=RESET>
> > > </font>
> > > </form>
> > >
> > >
> > > <?php
> > > $from = $FirstName ." ". $LastName;
> > > $subject = $Email;
> > > $message = $Info;
> > > mail("webmaster@domain.com, info@domain.com, $subject, $message,
$from);
> > > ?>
> > >
> >
> >
> > See, your syntax is incorrect :P
> >
> > Try:
> >
> > <?php
> > $from = $Email;
> > $subject = $Email;
> > $message = "Question from $FirstName $LastName:\n\n$Info";
> >
> > mail("webmaster@domain.com", $subject, $message, "From: $from\nCc:
> > info@domain.com");
> > ?>
> >
> > I'm assuming you wanted to send a copy to info@domain.com
> >
> > Please read the docs for mail(): http://php.net/mail
> >
> >
> > Regards
> >
> > Simon Garner
> >