E-A-S-Y question php syntax with mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

It is a very simple process.

if nothing is returned by print_r($_POST); then your $_POST variables are sent.

Are you sending the URL through the URL or a form?

--> if you are using the URL .. change $_POST to $_GET
Last edited by John Cartwright on Sat Mar 19, 2005 6:29 pm, edited 1 time in total.
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

Hawleyjr;

"The only 'intutive' interface is the nipple. After that, it's all learned." -Bruce Ediger

That's pretty funny!
(and true)
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

Hawleyjr;
Indeed this is one of those scripts you mentioned - and it works well. That is until I try to tweek it to use a dynamic email address via the variable "email" (vs the static email like email@snet.net)


Phenom;
I think it's sent via a form, but how would I know for sure?
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

PS : the flash swf file is not set up to receive anything from the php server side script... the flash swf just sends the variable "email" to this php script... then the php sends an email out
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

replace the $_POST WITH $_GET

Code: Select all

echo '<HR><PRE>'; print_r($_GET); echo '</PRE>';
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

Phenom;

Upon further reflection of your last post (POST vs GET) indeed this is sent via a form rather than a url...

Any thoughts?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

as I said before,

if

print_r($_POST);

returns nothing then your form was not submitted.
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

I'd never thought I'd live to say this but...
Further testing has revealed a flaw in my statement.

The problem appears to be one of domains - ie the server side php script below works ONLY if the variable "email" is an email in the same domain as the flash swf and server... is there a fix?


Code: Select all

<?php
$sendTo = $_POST["email"];
$subject = "*** instant email response ***";
$headers = "From: " . $_POST["email"] ." "."<" . $_POST["email"] .">\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = $_POST["name"] ."  (name)       ". $_POST["email"] ."  (email)       "; 

mail($sendTo, $subject, $message, $headers);
?>

feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

hawleyjr wrote:To Phenom's point about being the same to and from email address. some servers won't let email in that has the same domain name as the server domain name.
I'm sure this is the problem... is there a trick ??? (...set the right return path?)
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

change the send from in the headers.
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

hawleyjr wrote:change the send from in the headers.
Thanks for the reply... could you elaborate a bit?
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

Code: Select all

<?php
/***************************************************\
 * PHP 4.1.0+ version of email script. For more
 * information on the mail() function for PHP, see
 * http://www.php.net/manual/en/function.mail.php
\***************************************************/


// First, set up some variables to serve you in
// getting an email.  This includes the email this is
// sent to (yours) and what the subject of this email
// should be.  It's a good idea to choose your own
// subject instead of allowing the user to.  This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.

$sendTo = $_POST["email"];
$subject = "*** PASSWORD request ***";


// variables are sent to this PHP page through
// the POST method.  $_POST is a global associative array
// of variables passed through this method.  From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.


// header information not including sendTo and Subject
// these all go in one variable.  First, include From:
$headers = "From: CustomerService@CorporateCarPricing.com" . ">\r\n";
// next include a replyto
$headers .= "Reply-To: CustomerService@CorporateCarPricing.com" . "\r\n";
// often email servers won't allow emails to be sent to
// domains other than their own.  The return path here will
// often lift that restriction so, for instance, you could send
// email to a hotmail account. (hosting provider settings may vary)
// technically bounced email is supposed to go to the return-path email
$headers .= "Return-path: CustomerService@CorporateCarPricing.com" . "\r\n";


// now we can add the content of the message to a body variable
$message = "Congratulations ". $_POST["name"] . "!  Pending final CCP Membership confirmation, here is your Corporate Car Pricing user ID and password: ". $_POST["temppassword"]; 

// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);

?>
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Is the email address your trying to send to @CorporateCarPricing.com??

if so, try to send it to a hotmail or yahoo account to see if it works there.
forzato
Forum Newbie
Posts: 22
Joined: Sat Mar 19, 2005 5:49 pm

Post by forzato »

hawleyjr wrote:Is the email address your trying to send to @CorporateCarPricing.com??

if so, try to send it to a hotmail or yahoo account to see if it works there.

Actually I'm trying to send to the email address specified in the variable 'email'

Thanks again for your help!

PS script will send email if the 'email' variable is an address in the CorporateCarPricing.com domain - otherwise no go.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sounds like either the email server on the domain denies all external addresses, or the external addresses deny the email. Either can be the case.
Post Reply