E-A-S-Y question php syntax with mail
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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
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.
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?
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?
replace the $_POST WITH $_GET
Code: Select all
echo '<HR><PRE>'; print_r($_GET); echo '</PRE>';- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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?
feyd | Please review how to post code using
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
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]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);
?>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.