Iron Bridge Posted February 15, 2007 Share Posted February 15, 2007 I feel like a nuisance for asking such simple questions. I have a flash site for my upcoming wedding and within the site I have a guest form to collect addresses of our guests (for traditional invitations). The variables are sent via actionscript to a PHP script which then inserts the information into an SQL DB and emails both myself and the guest. In the email to the guest I would like to insert an animated .gif file as a signature. I know this is really simple yet I can't seem to get it to work. I have looked at the PHP manual and spent a good amount of time browsing forums and tutorials but to no avail. It comes down to my lack of knowledge of PHP syntax. I have pasted a sample of the code I am using with both email functions. Hopefully somebody can point out my error. I appreciate the help. As somone with essentially no PHP knowledge this forum has helped me tremendously. I find myself spending much more time in flash forums to help others as this forum has helped me. Anyways, I am off to go and click some advertisements. $thanks = "Dear " . $_POST['name'].","; $thanks .= "\n\n"; $thanks .= "Thank you for visiting our website........."; $thanks .= "\n\n"; $thanks .= "Sincerely,"; $thanks .= "\n\n"; $thanks .= $html; $thanks .= "\n\n"; $thanks .= "Alene and Sage"; $ouremail = "From: Alene and Sage <us@ouremail.us>"; $html = '<img src="images/ansSignature.gif">'; mail($sendTo, $subject, $message, $headers); mail ($_POST["email"], "Thank you for adding your address", $thanks, $ouremail); Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted February 15, 2007 Share Posted February 15, 2007 place your $html variable over your $thanks variables and place the $html in $thanks in quotes, like this: $html = '<img src="images/ansSignature.gif">'; $thanks = "Dear " . $_POST['name'].","; $thanks .= "\n\n"; $thanks .= "Thank you for visiting our website........."; $thanks .= "\n\n"; $thanks .= "Sincerely,"; $thanks .= "\n\n"; $thanks .= $html; $thanks .= "\n\n"; $thanks .= "Alene and Sage"; $ouremail = "From: Alene and Sage <us@ouremail.us>"; mail($sendTo, $subject, $message, $headers); mail ($_POST["email"], "Thank you for adding your address", $thanks, $ouremail); Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks for the timely reply. When I do this (place $html =... earlier in the script and $thanks .= "$html" the email displays: Dear ______, Thank you for visiting our website.......... Sincerely, <img src="images/ansSignature.gif"> Alene and Sage The actual image does not who up. Any ideas as to why? Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 15, 2007 Author Share Posted February 15, 2007 The <img> tag is not being read as HTML but rather plain text. Is there a PHP command to change this and have the $html read as HTLM and not text? Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 15, 2007 Share Posted February 15, 2007 Enclose your message in HTML by adding: $thanks = "<html><body>"; to the beginning (before anything else), and: $thanks .= "</body></html>"; to the end, before you send the message. If it still doesn't work then the email client probably doesn't read HTML emails. Quote Link to comment Share on other sites More sharing options...
maverick5x Posted February 15, 2007 Share Posted February 15, 2007 in $ouremail you will have to set an extra header for content-type which should be as far as i know text/html. Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 15, 2007 Author Share Posted February 15, 2007 So, I have placed: $thanks = "<html><body>"; $thanks .= .... $thanks .= "</body></html>; $ouremail .= "Content-type: text/html"; and I am still not getting the image. I know my mail client (Apple Mail) supports HTML email since I have made and received HTML emails before. Any more ideas? Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 15, 2007 Share Posted February 15, 2007 Change: $ouremail .= "Content-type: text/html"; To: $ouremail .= "\r\nContent-type: text/html"; \r\n is the standardized header field separator. Quote Link to comment Share on other sites More sharing options...
craygo Posted February 15, 2007 Share Posted February 15, 2007 Alot easier to link the image to your site rather than insert it. <img src=http://mysite.com/images/ansSignature.gif"> Now the pic will be in the e-mail from your web page rather than part of the e-mail Ray Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 15, 2007 Author Share Posted February 15, 2007 You guys are absolutely awesome. I finally got it woked out. I just had to change my $thanks .= "\n\n"; to $thanks .= "<br></br>; An example of the final code that I am using is listed below. This code delivers variables from a form via actionscrript 2.0 to a PHP script. The variables are then emailed to both me and the sender. I have designed the script to also implement the variables into an SQL DB but have left that part out. I hope this helps somebody in the future. $sendTo = "me@myemailaddress"; $subject = "whatever I would like it to be"; //All of the variable here are defined in flash through the variables dialog and not the instance name //I have found that using instance names produces less reliable results $headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; // now add the content of the flash message to a body variable. This creates a plain text email message $message = $_POST["message"]; $message .= "\n\n---------------------------\n"; $message .= "Mail sent by: " . $_POST['name'] . " <" . $_POST['email'] . ">\n"; $message .= "Our Address is: " . $_POST['address'] . " " . $_POST['city'] . "\n"; //HTML email with animated gif for signature $thanks = "<html><body>"; $thanks .= "Dear " . $_POST['name'].","; $thanks .= "<br></br>"; $thanks .= "Thank you for visiting our website........."; $thanks .= "<br></br>"; $thanks .= "Sincerely,"; $thanks .= "<br></br>"; $thanks .= '<img src="http://www.OurURL/images/ourGIF.gif"/>'; $thanks .= "<br></br>"; $thanks .= "Alene and Sage"; $thanks .= "</body></html>"; $ouremail = "From: Us <us@ouremail.us>"; $ouremail .= "\r\nContent-type: text/html"; mail($sendTo, $subject, $message, $headers); mail ($_POST["email"], "Thank you for adding your address", $thanks, $ouremail); Of course you could also add additional headers to the $thanks variable if you would like. I would like to tip my hat to the people who assisted me with this. I really appreciate the help. Sage http://www.aleneandsage.us http://www.ironbridge.vox.com http://www.sensationalsmyles.com Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.