header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Amina
Points:260
Posts:11

3/10/2010 7:05:16 AM

Title: sending mail


hello everybody
I am trying to develop sending mail within an application flex builder 3
So here is my php code


<!--
<?php
	$senderName = $_POST['senderName'];
	$senderEmail =  $_POST['senderEmail'];
	$sendToName = $_POST['sendToName'];
	$sendToEmail = $_POST['sendToEmail'];
	$emailMessage = $_POST['emailMessage'];
	$recipient = "$sendToEmail";
	$subject = "Hi there";
	$headers = "From: $senderEmail ";
	$message = "From: $senderName\nEmail Address: $senderEmail\nTo: $sendToName\nEmail Address: $sendToEmail\n\nMessage: $emailMessage";
	$message = StripSlashes($message);
	mail($recipient, $subject, $message, $headers)
?>
-->


and here is my code Felx


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
	<![CDATA[
		import mx.controls.Alert;
		import mx.rpc.events.ResultEvent ;
		public function sendEmail():void
		{
	    var senderName:String = senderName.text;
            var senderEmail:String = senderEmail.text;
            var sendToName:String = sendToName.text;
            var sendToEmail:String = sendToEmail.text;
            var emailMessage:String = emailMessage.text;
            this.emailService.send({senderName: senderName, senderEmail:senderEmail, sendToName: sendToName, sendToEmail: sendToEmail, emailMessage: emailMessage});
            if (cb.selected == true)
            {
                this.emailService.send({senderName: senderName, senderEmail:senderEmail, sendToName: sendToName, sendToEmail: senderEmail, emailMessage: emailMessage});
            }
		}
		  public function emailResult():void
        {
            Alert.show("Email Has Been Sent");
        }
	]]>
</mx:Script>
<mx:HTTPService id="emailService" url="./css/php/email.php" method="POST" resultFormat="xml" result="emailResult()" useProxy="false"/>
<mx:Panel width="510" height="449" >
		<mx:Text  width="100%" height="29" text="Simple Email Form" styleName="header" fontWeight="bold"/>
		<mx:HRule width="100%"/>
		 <mx:Form id="emailForm" width="100%" >
			 <mx:FormItem label="Your Name:" horizontalAlign="left" width="100%" fontWeight="bold">
	            <mx:TextInput id="senderName"  width="100%"/>
	        </mx:FormItem>
	        <mx:FormItem label="Your E-mail:" width="100%" fontWeight="bold">
	            <mx:TextInput id="senderEmail" width="100%"/>
	        </mx:FormItem>		 
	        <mx:FormItem label="Friends Name:" horizontalAlign="left" width="100%" fontWeight="bold">
	            <mx:TextInput id="sendToName"  width="100%"/>
	        </mx:FormItem>
	        <mx:FormItem label="Friends E-mail:" width="100%" fontWeight="bold">
	            <mx:TextInput id="sendToEmail" width="100%"/>
	        </mx:FormItem>
	        <mx:FormItem label="Message" horizontalAlign="left" width="100%" fontWeight="bold">
	            <mx:TextArea id="emailMessage"  width="100%" height="100"/>
	        </mx:FormItem>
		     <mx:FormItem width="100%" height="35">
		        <mx:Spacer width="200" />
		        <mx:Button id="submitBtn" label="Submit" click="this.sendEmail();"/>
		     </mx:FormItem>
		</mx:Form>
		<mx:HRule width="100%"/>
	</mx:Panel>
</mx:Application>
the problem is, there is no bug and no sending mail !!!!!!!!!!



Stewart
Points: 0
Posts:0
3/10/2010 9:44:29 AM



your code seems fine.

have you tested your php page by hard coding the values. there might be email server prob.
Just test your php page first by calling it in browser not by flex.

Ratti
Points: 0
Posts:0
3/10/2010 10:42:52 AM



to test your email server , run this php code .
open notepad paste this code, modify your email address to send mail and also from address and save as testmail.php
upload to your server and open url

http://yourdomain.com/testmail.php

it should send mail , see if it works .



<?php  

    mail("toyouremail@youremail.com", " Test subject"," Test message", "fromyouremail@yourdomain.com");
	echo " test email sent";
?> 


Amina
Points: 260
Posts:11
3/10/2010 1:28:20 PM



hello and thank you for answers
I come back after my tests

Amina
Points: 260
Posts:11
3/10/2010 1:47:14 PM



hi!still me.
knowing that I work locally so in my HTTPService:
////////////

<mx:HTTPService id="emailService" url="http://localhost/testmail.php "method="POST" resultFormat="xml" result="emailResult()" useProxy="false"/>

///////////////////
and here is the error that sent me flex


[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Erreur de flux. URL: http://localhost/testmail.php"]. URL: http://localhost/testmail.php "]
	at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:220]
	at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:53]
	at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
	at DirectHTTPMessageResponder/errorHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:362]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at flash.net::URLLoader/redirectEvent()

Ronaldo
Points: 0
Posts:0
3/10/2010 3:28:31 PM



is your email server setup properly,

check your page path by entering this path in your browser

http://localhost/testmail.php

after opening page see if it sends mail.

the above error is IO error which means the page is not available or accessible .
place your swf file and php file in same directory to avoid security error.I mean to say the swf should be also inside localhost directory.

Dave
Points: 680
Posts:1
3/10/2010 10:10:20 PM



Hi amina , I have found your bug. On running your php page i got error regarding some line ending format wrong. To fix it replace all your newline \n with \r\n in message body like this :

$message = "From: $senderName\r\nEmail Address: $senderEmail\r\nTo: $sendToName\r\nEmail Address: $sendToEmail\r\n\r\nMessage: $emailMessage \r\n";

In your flex code there was error for "cb.selected" so I removed the condition.

I have tested your flex code with your php code after fixing and it works like charm.




Amina
Points: 260
Posts:11
3/11/2010 12:10:34 PM



hi
oh thank you dave is very nice of you :D
and of course thank you to all who helped me in this super cool forum


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 7+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions