Sending an E-mail with attachment with PHP from Flex

Hey,
I've made a custom compontent wich mails your own drawings to you. But I have a problem to send an e-mail with attachment.
I use the HttpService to send the data to the php-file, but I always get the Fault message (form phpFault()).
This is my code in Flex:
<mx:Script>
    <![CDATA[
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import mx.graphics.codec.PNGEncoder;
        import mx.events.ValidationResultEvent;
        import mx.controls.Alert;
        [Bindable]
        private var byteArray:ByteArray;
        private function mailImage(comp:DisplayObject):void
            var emailValidation:ValidationResultEvent = validEmail.validate();
            if(emailValidation.type == ValidationResultEvent.INVALID)
                Alert.show("Invalid E-mail");
            else
                var bitmapData:BitmapData = new BitmapData(comp.width, comp.height);
                bitmapData.draw(comp);
                var png:PNGEncoder = new PNGEncoder();
                byteArray = png.encode(bitmapData);
                httpMail.send();
        private function phpResult(evt:ResultEvent):void
            Alert.show("You've got mail.");
        private function phpFault(evt:FaultEvent):void
            Alert.show("Something went wrong. /n" + evt.message.toString());
    ]]>
</mx:Script>
<mx:EmailValidator id="validEmail" source="{ipEmail}" property="text"/>
<mx:HTTPService id="httpMail" url="php/byte-receiver.php" method="POST" result="phpResult(event)" fault="phpFault(event)">
    <mx:request>
        <img>{byteArray}</img>
        <mail>{ipEmail.text}</mail>
    </mx:request>
</mx:HTTPService>
<mx:Label text="draw your own image" styleName="h1" x="10" y="0" width="493" height="60"/>
<mx:Canvas
    id="drawCanvas"
    x="10" y="77"
    width="561" height="245"
    borderStyle="solid" borderColor="#A6A6A6">
</mx:Canvas>
<mx:Label x="10" y="329" text="Your e-mail:" styleName="text"/>
<mx:TextInput
    id="ipEmail"
    x="86" y="324" width="417"/>   
<mx:Label
    id="lblMailImage"
    x="10" y="383"
    text="Mail my image"
    click="mailImage(drawCanvas)"
    mouseOver="lblMailImage.setStyle('color',  '#00067b')"
    mouseOut="lblMailImage.setStyle('color',  '#717171')"
    styleName="button"/>
</mx:Canvas>
This is my PHP code
<?php                 
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = "ImgContact.png"; // Filename that will be used for the file as the attachment
$email_from = "[email protected]"; //Who the email is from
$email_subject = "Contact Winckelmans.net"; // The Subject of the email
$email_message = "Mail send by winckelmans.net. Your drawing is in the attachment"; // Message that the email has in it
$email_to = $_POST['mail']; // Who the email is too
$headers = "From: $email_from";  
$data= $_POST['img'];
$semi_rand = md5(time());  
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  
$headers .= "\nMIME-Version: 1.0\n" .  
            "Content-Type: multipart/mixed;\n" .  
            " boundary=\"{$mime_boundary}\"";  
$email_message = "This is a multi-part message in MIME format.\n\n" .  
                "--{$mime_boundary}\n" .  
                "Content-Type:text/html; charset=\"iso-8859-1\"\n" .  
               "Content-Transfer-Encoding: 7bit\n\n" .  
$email_message . "\n\n";  
$email_message .= "--{$mime_boundary}\n" .  
                  "Content-Type: {$fileatt_type};\n" .  
                  " name=\"{$fileatt_name}\"\n" .  
                  //"Content-Disposition: attachment;\n" .
                  //" filename=\"{$fileatt_name}\"\n" .
                  "Content-Transfer-Encoding: base64\n\n" .  
                 $data . "\n\n" .  
                  "--{$mime_boundary}--\n";  
$mailsend = mail($email_to, $email_subject, $email_message, $headers);  
echo $mailsend;
?>
This is the error I get in an Alert:
(mx.messaging.messages::ErrorMessage)#0
  body = ""
  clientId = "DirectHTTPChannel0"
  correlationId = "F3C16CE1-65CF-E690-1907-D28293FD6BB9"
  destination = ""
  extendedData = (null)
  faultCode = "Server.Error.Request"
  faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: php/byte-receiver.php"]. URL: php/byte-receiver.php"
  faultString = "HTTP request error"
  headers = (Object)#1
    DSStatusCode = 0
  messageId = "7A1DCDBE-0358-7E39-3AF8-D282945A7748"
  rootCause = (flash.events::IOErrorEvent)#2
    bubbles = false
    cancelable = false
    currentTarget = (flash.net::URLLoader)#3
      bytesLoaded = 0
      bytesTotal = 0
      data = ""
      dataFormat = "text"
    eventPhase = 2
    target = (flash.net::URLLoader)#3
    text = "Error #2032: Stream Error. URL: php/byte-receiver.php"
    type = "ioError"
  timestamp = 0
  timeToLive = 0
Thanks in advance
Vincent

Hi
I'm having the same issue, except my application actually sends the email but the attachment is 0 octet and it doesn't even give me an error... Any chance you found a solution for this and could share it ?
Thanks

Similar Messages

  • XI Mail Adapter: sending emails with attachment with help of java mapping

    Hi ,
    On trying out the scenerio mentioned in the blog, using the java mapping provided
    "XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    The scenerio works just fine.
    But the payload as the content of the attachment is not getting generated in proper XML format.
    I suppose it's because of the replace special characters code part..
    Can anyone help me state the modification required in the code.
    Thanks!
    Regards,
    Faria Mithani

    It might be a codepage issue. Is your original payload UTF-8?

  • "Send an E-Mail in Background with Attachment (Optional)" can't  be called

    hi
    i tried notice from gp's mail template via other object.
    it's successed.
    but when i tried CO "Send an E-Mail in Background with Attachment (Optional)", and code like follows:
              IGPStructure params = GPStructureFactory.getStructure(process.getInputParameters());
              params.setAttributeValue("email_address", receiverMailAddress);
              params.setAttributeValue("customer_Name", receiverName);
              params.setAttributeValue("context", context);
              if (document != null) {
                   IGPStructure attachment = params.addStructure("ATTACHMENT_1", "com.sap.caf.eu.gp.types.File");
                   attachment.setAttributeValue("Name", "com.sap.caf.eu.gp.types.File", documentName);
                   attachment.setAttributeValue("ContentType", "com.sap.caf.eu.gp.types.File", documentContentType);
                   attachment.setAttributeValue("Size", "com.sap.caf.eu.gp.types.File", document.length);
                   attachment.setAttributeValue("Content", "com.sap.caf.eu.gp.types.File", document);
    it ain't work.
    also, did not throw any exception.
    i found some exception message from log viewer
    null
    com.sap.caf.eu.gp.base.exception.EngineException
    at com.sap.caf.eu.gp.model.fnd.mail.MailSendingUtility.sendMailThrowsExc(MailSendingUtility.java:889)
    at com.sap.caf.eu.gp.model.fnd.mail.MailSendingUtility.sendMailThrowsExc(MailSendingUtility.java:837)
    at com.sap.caf.eu.gp.callobj.mail.NotificationCOwithAttachment.onExecute(NotificationCOwithAttachment.java:394)
    at com.sap.caf.eu.gp.callobj.bckgd.base.AbstractBackgroundCallableObject.execute(AbstractBackgroundCallableObject.java:102)
    at com.sap.caf.eu.gp.callobj.container.BackgroundCallableObjectsContainer.execute(BackgroundCallableObjectsContainer.java:82)
    i work with netweaver 7.11 ehp1 sp3.
    please help if you can, thank you very much.

    Hi, Dipankar:
    Thanks for your reply. But I have no idea about how to group parameter from all uploaded file to "Send an E-Mail in Background with Attachment" CO?
    For the situation, I write a background CO program to get all uploaded file (from first three block) and grouping this customized CO parameter with "Send an E-Mail in Background with Attachment" CO.

  • Add many attachment to CO "Send an E-Mail in Background with Attachment"

    Hi, experts:
    I create a guided procedure which contain 4 sequential block.
    in first 3 block, every user will upload their own file.
    In the last block, I want collect all uploaded file, and pass to CO "Send an E-Mail in Background with Attachment" to mail to the user who assign to the fourth block.
    Any idea about what block type I should use in fourth block?
    Thanks in advance.

    Hi, Dipankar:
    Thanks for your reply. But I have no idea about how to group parameter from all uploaded file to "Send an E-Mail in Background with Attachment" CO?
    For the situation, I write a background CO program to get all uploaded file (from first three block) and grouping this customized CO parameter with "Send an E-Mail in Background with Attachment" CO.

  • Hi there, i can't send letter using Mail on Mac with AOL mail.

    Hey there, i can't send letter using Mail on Mac with AOL mail. But i can receive all letters.
    Also using iCloud in Mail. What to do? Or maybe i can send letters only from iCloud/Me mail if i am using more than one mailbox in Mail?
    Thanks

    Troubleshooting sending and receiving email messages
    Troubleshooting sending email messages

  • When I send an e-mail to a group address, from my address book, I get an error messageI get an error message that one of them is not a valid e-mail address, although I have used it alone without any problem.

    When I send an e-mail to a group address, from my address book, I get an error messageI get an error message that one of them is not a valid e-mail address, although I have used it alone without any problem.

    See https://support.mozilla.org/en-US/questions/1018363

  • Sending mail with attachment with a JWS deployed app

    Hi,
    I'm trying to solve this problem: I have an application which provides the possibility to send e-mail message with various kind of attached file (such as pdf, doc, txt, ...). The application uses JAF and JavaMail libraries and it works fine when I run it normally (without using webstart). When I deploy the app with JWS I got an exception when I request to send the e-mail message. The exception is:
    javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed
    I read a post in this forum in which the writer says that he solved this problem putting the mailcap file into his jar archive, but he didn't specify where exactly the mailcap file must be located and which mailcap file include in the jar archive.
    Any help would be very appreciate.
    Giacomo.

    I solved it, duke dollars return in my pockets...

  • I send an e-mail every week with an attachment to 4 people since I got Firefox they don't arrive at their destination. Any ideas?

    I used Internet explorer but was having difficulties reading "sky's" e-mails, I was recommended by Sky to use Firefox. I can now read the e-mails but when I send an e-mail and an attachment, to 4 addressees (which I have done every week for about 5 years, using internet explorer) they don't arrive at any of the intended destination, can anyone give me a solution to my problem. Thanks

    Hi thanks for the response,
    I haven't tried to send an attachment to myself, not sure exactly how to do that but I'll have a look Friday/Saturday when I get home.
    As to the mail system, I use Sky's e-mail, as I said it use to work perfect on Internet explorer until Sky changed the format of their e-mail page, then I was unable to scroll up or down the page. So I was advised by Sky to use Firefox

  • Problem Mail-Adapter attachment with specified name

    Hi,
    We have the following scenario:
    We have some EDIFACT-suppliers which we have to connect over Mail-adapter.
    We have to fullfill several specifications by sending the mail.
    So we have to create a specific filename for the EDI-attachment and the subject. Therefore I used the adapterspecific attribute THeaderSUBJECT, which we set in Mapping. This works fine.
    Now the problem: We have to send only the payload-document as attachment of the mail with the same name as the subject of the mail. So we can't use the keep-attachment flag because then all attachments of this message would be sent in the mail.
    How is it possible to send only the payload as attachment without any other documents and with specified filename in the attribute THeaderSUBJECT?
    Has anybody an idea how to solve this problem?
    Regards
    Thorsten

    Hi,
    I have found a solution.
    In a new module I copy the original paload to the payload of a new message object without attachments.
    After calling this module I call the standard module MessageTransformBean to transform the payload into the attachment of the message.
    Here the code of my module:
    String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/Mail","THeaderSUBJECT");
    // Generate new message object
    Context ctx = new InitialContext();
    ConnectionFactory cf = (ConnectionFactory) ctx.lookup(com.sap.aii.af.ra.ms.api.ConnectionFactory.JNDI_NAME);
    MessageFactory factory = cf.createMessageFactory("XI");
    Message msgnew = factory.createMessage(msg.getFromParty(),msg.getToParty(),msg.getFromService(),msg.getToService(), msg.getAction());
    msgnew.setConversationId(msg.getConversationId());
    msgnew.setDeliverySemantics(msg.getDeliverySemantics());
    msgnew.setCorrelationId(msg.getMessageId());
    msgnew.setMessageProperty("http://sap.com/xi/XI/System/Mail","THeaderSUBJECT",fileName);
    String contentType = new String("text/plain;name="" + fileName + """);               
    // Copy original message to the new message
    XMLPayload payload = (XMLPayload)(msg.getDocument());
    payload.setContentType(contentType);
    payload.setDescription("file");
    payload.setName(fileName);
    msgnew.setDocument(payload);
    Now it works like it should work.
    Regards
    Thorsten

  • Send ABAP Report as an Attachment with Workflow Function Module

    Hi all.
    Hopefully someone ever experienced with this requirements.
    My requirements to send ABAP Report result to user as an attachment. Together with this attachment user need to receive work item/notification. Single workflow task has been defined based on SELFITEM object type to send workflow notification and its attachment.
    Function module for this requirement is SWU_START_WORKFLOW. And this function module provide table parameter ATTACHMENT_LIST.
    My question how to pass this ABAP report result/ ABAP internal table into this ATTACHMENT_LIST?
    Thanks in advance

    check the help on the SUBMIT statement ther are options to write the report to memory or spool.
    Kind regards, Rob Dielemans

  • Need Help with send raw xml to PHP from flex

    Hello all,
    I am trying to pass raw XML from flex to php.
    I can pass the data using get but need to use POST.
    When I submit the data via POST
    the data is not available in $HTTP_RAW_POST_DATA.
    Any help is greatly appreciatted

    Hello all,
    I am trying to pass raw XML from flex to php.
    I can pass the data using get but need to use POST.
    When I submit the data via POST
    the data is not available in $HTTP_RAW_POST_DATA.
    Any help is greatly appreciatted

  • Friends on Android galaxy do not receive my emails with attached photos sent from my iPhone.  Why

    I have an iPhone 4 running 6.1 OS.  Several times I have taken photos with my iPhone and then tried to email them from my iPhone to friends using Android Galaxy.  They never receive the emails. When I select the photo to be emailed from "Camera Roll", several options appear  (Mail, Message, Photo Stream, Twitter, Facebook etc).  I select "Mail", then select an email address from my contact list, add some text to the message, select the size of photo and send.  The email with attached photo is never received.  Any idea why?

    Well, your response about MMS is beyond my understanding unfortunately.   Don't understand too well this issue of MMS and IMessage. I checked my settings and "Send as MMS" was OFF.  I have turned it ON and tried to re-send the photos.  No word yet if it was received..  Also, the "send and receive" addresses in the "Messages" setting only included my "@me" email address, and not my Yahoo address, which I am trying to add.  It doesn't seem to be able to complete the verification process for that Yahoo address (it remains in a perpetual state of "verifying"), although it did add an "icloud" address, and my cell phone number.   I have my "cellular data" turned OFF because I am in the States (I am Canadaian) and wish to restrict roaming charges.  So are you saying that I cannot send photo attachments in emails from my iPhone, while connected to the in-house internet modem/router - ie., that I can do so only if my "cellular data" setting is ON?  Then why do the messages still appear in the SENT folder?  Do the settings on the recipient phone have an impact?  It doesn't seem so because they were able to receive the messages from the PC/Hotmail source.

  • New email with attachment action disappeared from Finder

    Does anybody know what might have happened? I've been using this action for some time, and after upgrading to Mountain Lion it stopped working. Then after some time I discovered that the action is no longer available in the Finder context menu.
    Note: I'm using Bitcasa, and the Bitcasa client added some actions of its own under an option called "services".The action "new email with attachment appeared under "services" as well.
    I don't think it's a Bitcasa problem as it's been working just fine for several months now. It crapped out after upgrading to ML.

    Nevermind, figured it out elsewhere on the suport forum.
    https://discussions.apple.com/thread/4139642?start=15&tstart=0
    Aruk
    Do this from in the mail app. Change it to Mail 6.0.
    "Hey, mine seems to be working now, what i did; i change the email preferences>general the first options reads: "default email reader" mine used to read "google chrome", after i changed the preferences the "share" button now shows all the options including "email". hope this helps in some way:D"

  • Processing ArrayCollection or XML in PHP from Flex

    I know this is a Flex forum, but after I use HTTPService with
    POST and an ArrayCollection or XML object as the parameter, anybody
    have the PHP code I would use to grab the parameter on the server
    side?
    Once I have grabbed it and put it in a PHP variable I can
    figure out the rest.
    Thanks!

    One caveat for POST ing XML from AIR is that there is a bug
    and it submits as GET instead. Work-around I had to use was to
    upload XML file instead and then parse it.... otherwise from FLEX
    If you POST the XML as a parameter like so
    var params:Object = new Object()
    params.postText = myXML
    myHTTPService.send(params)
    and your XML is something like.....
    <root>
    <record><data>mydata</data></record>
    </root>
    then the PHP script looks something like.........
    foreach($_POST AS $key => $value) { ${$key} = $value; }
    if(isset($postText)){
    //echo $postText;
    $xml = new SimpleXMLElement($postText, LIBXML_NOCDATA);
    $record = $xml->record;
    // use first record to capture column names into array
    foreach($record[0]->record->children() as $col){
    $colNames[] = $col->getName();
    // then for each column , record get the values
    foreach($record->record as $row){
    foreach($colNames as $column){
    $values[] = $row->$column;
    //do something with the record
    else{
    exit;
    //get record level element name;
    $act = $xml->act;
    $table = $xml->table;
    $record = $xml->records;
    // get column names

  • Send PDF form to e-mail as attachment with a PHP script on the server

    Hi,
    For several days I've been searching though the internet looking for a solution, a quite simple one in my opinion, but I got a little desperate not getting any result I want.
    Okay. The Situation.
    I have a PDF form to order sandwiches and drinks.
    The PDF has serveral area's and columns where customers fill in the amount of the products they would like to order.
    At a position of a field, the kitchen can almost blindly see what products a customer ordered.
    Therefore, when someone fills in the form, I want to send the filled PDF by e-mail to the kitchen's e-mail adress. And important: the PDF in the kitchen's mailbox should be completely identical to the form the customer filled in.
    So, I have an Order button in my form. I set the action as 'Submit a form'.
    In the settings under 'Enter a URL for this link' I used just some PHP mailer script I also use on my website contact form.
    IF I check 'HTML' under 'Export Format' the PHP mailer works fine. I receive an HTML e-mail listed the ordered products.
    BUT
    I do want the original filled PDF in my mailbox instead of an HTML e-mail.
    So, for 'Export Format' I checked 'PDF The Complete Document'.
    But then my PHP mailer script doesn't work anymore.
    It gives errors like 'no valid e-mail adres' , etcetera etcetera.
    Who has a solution?
    Who has a working standard PHP script for me what just sends the kitchen an empty mail with the original PDF as attachment?!
    There is no need to use any database or other more complex functionality. Just mail the filled PDF.

    You can submit whole PDF format as long as you enable usage rights on the PDF.
    Normally Adobe Reader users can only submit the data, XFDF, FDF, XDP, XML.
    To enable usage rights on the PDF you will need to use Adobe Acrobat Std/Pro.
    As for the PHP Script; it depends on your PHP web server capabilities.
    The script will be slightly different, if the server uses PHP Mail or PHP PEAR.
    Just attach the submission to an email and send.
    If the client is submitting the form from a standalone pdf reader app, you can also respond with a success or failure FDF \status message; otherwise, you can redirect to a success / failure URL.
    For more information and online examples:
    http://www.pdfemail.net/examples/

Maybe you are looking for

  • Can I create a windows 7 partition on a 1TB thunderbolt drive to use with my Macbook Pro?

    I have a new Retina Display Macbook Pro with a 250gb SSD Drive that is quickly running out of space. My work recently gave me a new project to do some programming that can only be done in a Windows environment. With the price of Thunderbolt drives co

  • How to change background color only in specific pages???

    Hi! I try to change color of background in pdf document using adobe reader, but it only changes all pages together and I can't find a way to do it on selected pages(or even select them). For example I need to change only 1st and last page to grey bac

  • Position button at the end of ALV grid

    Hi, I have a requirement to place position button (like in OB52 or any table/view maintenance ) to search and position the record on the top of list. I have placed the position pushbutton with function code and have called TABLE_GET_KEY_TO_SET_CUR_RO

  • WebDynpro on Windows Mobile 5.0 doesn't work

    Hi, SORRY: I JUST REALISED I POSTED THIS TO THE RFID FORUM : PLEASE IGNORE. We tried running a Web Dynpro application on an i-mate JASJAR Pocket PC running Windows Mobile 5.0 (OS 5.1.1700 (Build 14354.0.1.1), however when any action is initiated (eg

  • Data loosing in Hyperion Enterprise 6.5.1.

    We lost second time within one week all data in the Actual 2010 category. There is no identifier in the event log. User access is over terminal server. Has someone experienced such a problem? Ender