PDA

View Full Version : Tiny help with an example



travisperkins
02-10-2006, 12:40 PM
I am starting a new thread for this repeat post because I am so close I am afraid it will get lost in the previous one.

I am attaching an example of an am6 project that has the skeleton for everything I need except that I can not work out where in the am6 code I would place the address of the php mailer script on my server so that, when I click 'send', the on click event knows where to submit to.

This example is from:

http://www.indigorose.com/forums/showthread.php?p=75127

and the php script on my server contains:

<?php

$mail_to = $_REQUEST['mail_to'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$mail_from = $_REQUEST['mail_from'];
$reply_to = $_REQUEST['reply_to'];

$headers = "From: $mail_from\r\n";
$headers .= "Reply-To: $reply_to\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";

mail(
$mail_to,
$subject,
$message,
$headers
);

?>

bule
02-10-2006, 12:50 PM
I replied to you in your previous thread.

For this one, try using $_POST in your php code instead of $_REQUEST

travisperkins
02-10-2006, 12:54 PM
OK. But (and forgive me if this is daft and don't be afraid to tell me so); but how does AM6 know to submit the mail to http://www.karazoo.com/mailscript.php

It is not entered anywhere in the AM6 application events.

travisperkins
02-10-2006, 12:58 PM
Just to be more helpful.

This is the only code in the am6 exampel project. It does not conatin anything that would tell the am6 application that the php script is ont he server at http://www.karazoo.com/mailscript.php

So how can it work?

travisperkins
02-10-2006, 01:01 PM
Sorry: forgot the code:

This is the code from the project that lacks any reference to the php script.

sEmailTo = Input.GetText("iEMailAddress");
sMailFrom = String.Concat("AMS Test User", "<biz@karazoo.com>");
sReplyTo = String.Concat("AMS Test User", "<biz@karazoo.com>");
sSubject = String.Concat("System Information for ", ""..ComputerName);

sMessageBody = Table.Concat(tEmailBody, "\r\n", 1, TABLE_ALL)

SubmitValues = {};
SubmitValues.mail_to = ""..sEmailTo;
SubmitValues.reply_to = ""..sReplyTo;
SubmitValues.mail_from = ""..sMailFrom;
SubmitValues.subject = ""..sSubject;
SubmitValues.message = ""..sMessageBody;

Page.Jump("Send");

Dermot
02-10-2006, 01:28 PM
Can't see anything wrong with the AMS part. You seem to have the submit part correct. You do realize that the submit code is on another page and you are jumping to it. Might be better to just put it all on one page and add a label that says "Please Wait" or something like that. You might want to check that there are values in the input fields before submiting though.

In the PHP file I don't think you need the Requests. The variables passed in from AMS will be available. You just need to add the $ to them. Well I have never used request and it has always worked for me.

This should be all you need:


<?php

$headers = "From: $mail_from\r\n";
$headers .= "Reply-To: $reply_to\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";

mail(
$mail_to,
$subject,
$message,
$headers
);

?>

You can also return a message from your PHP script to AMS like this.


echo "Your email has been sent."

It would be a good idea to check that the mail() function succeeded and return an appropriate message.

By the way your project is AMS 5 not 6.

travisperkins
02-10-2006, 01:56 PM
I was looking ont he wrong page for the submit script.

Thanks !