Page 1 of 1

How can I get this php mailer working in Canvas?

Posted: Fri Feb 21, 2020 11:35 pm
by izlude
Hi all. I've been rebuilding an old site of mine for a few years, finally got most of it working... all except the mailer. This is a php e-card mailer, but it involves JS since this is an Adobe Animate HTML5 Canvas project. I for the life of me can't figure out how to get it implemented on my canvas project. Posted on Adobe forum, no dice, tried researching it, confusing as heck. The fact that I got most of the site going gives me hope, it's such a SMALL piece and I'd be ever so grateful if anyone out there could just... give me a magic answer :D

OK here's the code:

Send Button Code:

Code: Select all

this.sendbutton.addEventListener('click', bF.bind(this));
function bF() {
	if ($('#ToName').val() == "") {
		this.Status.text = "please enter a to name";
	} else
	if ($('#ToEmail').val() == "") {
		this.Status.text = "please enter a to email";
	} else
	if ($('#FromName').val() == "") {
		this.Status.text = "please enter a from name";
	} else
	if (FromEmail = "") {
		Status = "Please enter your email address";
	} else
	if ($('#Greeting').val() == "") {
		this.Status.text = "please enter a greeting";
	} else
	if ($('#IntroMessage').val() == "") {
		this.Status.text = "please enter a message";
	} else {
		this.Status.text = "Sending Ecard - Please Hold";
                /*actual send function should either go right here,
                    or just on the frame it's about to jump to*/
		this.gotoAndStop(2);
	}
}
*Originally taken from my flash version, I changed it to work in the canvas.
*ToName, FromName, ToEmail, IntroMessage, Greeting = text input Components of the same instance names.
*FromEmail, Status, SelectEcard = dynamic text boxes, same instance name.
*This button just needs a function that loads SelectEcard php.

I originally used this in flash, but need some other solution:

Code: Select all

loadVariablesNum ("SendEcard.php", 0, "POST");
SendEcard php file:

Code: Select all

<? 
register_globals( 'NGPCFRES' );

$CreateEcard = date(U); 
$filename = $CreateEcard.".txt"; 
$ToEmail = $_POST["ToEmail"]; 
$FromEmail = $_POST["FromEmail"]; 
$ToName = $_POST["ToName"]; 
$FromName = $_POST["FromName"]; 
$Greeting = $_POST["Greeting"]; 
$IntroMessage = $_POST["IntroMessage"]; 
$EndMessage = $_POST["EndMessage"]; 
$EcardSelect = $_POST["selected"]; 
$Today = (date ("l dS of F Y ( h:i:s A )",time())); 
$Created = "Ecard Created on $Today"; 
$EcardNum = $_POST['EcardSelect'];
$EcardText = "ToName={$_POST['ToName']}&ToEmail={$_POST['ToEmail']}&FromName={$_POST['FromName']}&FromEmail={$_POST['FromEmail']}&Greeting={$_POST['Greeting']}&IntroMessage={$_POST['IntroMessage']}&Created={$_POST['Created']}&"; 
$fp = fopen( "dBText/$filename","w"); 
fwrite($fp, $EcardText, 10000); 
fclose( $fp ); 
######Email Card######## 
## You can change the subject and the message part around. 
## Make sure to change the Link as stated in the Tutorial. 
## (Change from 'someSite' to your actual site - leave the rest the same 
$ToSubject = "E-card from $FromName"; 
$Message = "$ToName,\nYou have recieved a Flash E-card from $FromName. \nClick the following link to view your card:\n\n http://www.MYSITE.net/SelectCard.php?EcardText=$CreateEcard&ENum=$EcardNum\n\n-----------------------------------\nHere is the message that was sent:\n$ToName,\n$Greeting\n$IntroMessage\n\n-$FromName\n\n\n-----------------------------------\nThis card was sent by Bunny and Panda\n\nMaking you smile a little more each time."; 

mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FromName." <".$FromEmail.">"); 

## This next line returns a success message to the movie. 
print "_root.holder.Status=\n Copy the following link to view your card:\n http://www.MYSITE.net/SelectCard.php?EcardText=$CreateEcard%26ENum=$EcardNum\n"; 

function register_global_array( $sg ) {
    Static $superGlobals    = array(
        'e' => '_ENV'       ,
        'g' => '_GET'       ,
        'p' => '_POST'      ,
        'c' => '_COOKIE'    ,
        'r' => '_REQUEST'   ,
        's' => '_SERVER'    ,
        'f' => '_FILES'     ,
        'n' => '_SESSION'
    );
    Global ${$superGlobals[$sg]};
    foreach( ${$superGlobals[$sg]} as $key => $val ) {
        $GLOBALS[$key]  = $val;
    }
}
function register_globals( $order = 'gpc' ) {
    $_SERVER;       //See Note Below
    $_ENV;
    $_REQUEST;
    $order  = str_split( strtolower( $order ) );
    array_map( 'register_global_array' , $order );
}
?>
*The code, unchanged, as it was used for my Flash site
*Confused as to whether or not ToName, FromName etc... need to reflect the same format as used in my button's code

Code: Select all

($('#ToName').val()
or just keep it as

Code: Select all

$ToName = $_POST["ToName"]; 
basically asking for someone to auto-correct >.< thanks...
*The line "print root holder status" I'd like it to change it to print to a text input component called "Grab", and it's not located in holder anymore, it's just there in the base timeline.

The cards themselves used to use this code in Flash, so I'm only posting it to show you what it is I was doing back then, so I guess I need another way now:

Code: Select all

loadVariablesNum ("http://www.MySite.net/dBText/"+EcardText+".txt", 0);
Here's the SelectCard php for reference, not sure if anything here needs changing...

Code: Select all

<HTML>
<HEAD>

<TITLE>Here's your Ecard - from Bunny & Panda E-Cards</TITLE>

<?
register_globals( 'NGPCFRES' );

function register_global_array( $sg ) {
    Static $superGlobals    = array(
        'e' => '_ENV'       ,
        'g' => '_GET'       ,
        'p' => '_POST'      ,
        'c' => '_COOKIE'    ,
        'r' => '_REQUEST'   ,
        's' => '_SERVER'    ,
        'f' => '_FILES'     ,
        'n' => '_SESSION'
    );
    Global ${$superGlobals[$sg]};
    foreach( ${$superGlobals[$sg]} as $key => $val ) {
        $GLOBALS[$key]  = $val;
    }
}
function register_globals( $order = 'gpc' ) {
    $_SERVER;       //See Note Below
    $_ENV;
    $_REQUEST;
    $order  = str_split( strtolower( $order ) );
    array_map( 'register_global_array' , $order );
}

switch ($_GET['ENum']) {

## Birthday Cards

    case '1':
    $goto = "ecards/birthdaycards/birthday1.html?EcardText=".$EcardText;
    $Dimensions = "WIDTH=700 HEIGHT=564";
    break;

    case '2':
    $goto = "ecards/birthdaycards/birthday2.html?EcardText=".$EcardText;
    $Dimensions = "WIDTH=700 HEIGHT=564";
    break;

}

?>

<?php

$url = 'http://www.MySite.net/images/wallpaper.png';

?>
</head>

<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" rightmargin="0" marginheight="0" marginwidth="0">
<br>
<br>
<br>
<br>
<center>
<OBJECT
 <? print "$Dimensions";?>>
 <PARAM NAME=movie VALUE="<? print "$goto";?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="<? print "$goto";?>" quality=high bgcolor=#FFFFFF  <? print "$Dimensions";?></EMBED>
</OBJECT>
</center>
<style type="text/css">
body
{
background-image:url('<?php echo $url ?>');
}
</style>
</BODY>
</HTML>
Final note: I might actually drop the e-mail feature and just have it so that users can just grab the generated link and paste it onto social media/chat etc... back in 2010, I think people cared a little more about checking e-mail for such things, but these days it'd be better for just pasting a link. Although if anyone has a solution for this topic, maybe leave the e-mail capability in for now and I'll remove it myself later if I decide on it x) Thanks a million.