Jump to content

[SOLVED] Insert image into PHP generated email


Iron Bridge

Recommended Posts

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);

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.