Jump to content

Embedded images


Drakkie

Recommended Posts

Hello there,

i hope you guys/gals can give me some help on this case. I need a working attachment thing for my website to send e-cards. I am so glad that after a long while i got the email thing to work. but i cant figure out on how to get the embedded stuff. I sincerely hope you can help. this has to be finished before monday unfortunately,so please hurry a bit :D i hope you can be my saviour :D. My current code is as posted below and attachment name= "ecard1.jpg".

<?php
// controleren of de pagina zichzelf heeft aangeroepen.
// Zo ja, de e-mail verzenden.
if (!empty($_POST)){

$bedankt_pagina = "ecards.html";
// variabelen voor mail() initialiseren. In werkelijkheid nog beveiliging/validatie toevoegen!
$ontvanger = $_POST["email_vriend"];
$onderwerp = $_POST["eigennaam"] . " heeft je een e-card gestuurd";
$bericht = "Je hebt een bericht ontvangen van " . $_POST["eigennaam"] ;
$bericht .= "(". $_POST["eigen_email"] ."). Hij schrijft het volgende: \n\n";
$bericht .= $_POST["bericht"];

// het e-mailbericht verzenden
if (!mail($ontvanger, $onderwerp, $bericht)){
echo "Er is een fout opgetreden bij het verzenden van e-mail";
}
else{
// succesvol verzonden, doorsturen naar bedankt-pagina
header("location:$bedankt_pagina");
}
}
else{

?>
<html>
<head>
<title>Voorbeeld 8.2 - vertel een vriend</title>
</head>
<body>
<h1>Verzend je e-card</h1>
Op deze pagina kun je de e-card bekijken op zijn volledige grootte en kun je hem bovendien versturen door enkele gegevens in te vullen.<p>
<a href="ecard1.jpg"><img src="ecard1.jpg"height=400"></a>
<hr>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
Je eigen naam : <input type="text" name="eigennaam"><br>
Je eigen e-mailadres :<input type="text" name="eigen_email"><br>
<hr>
Naam van de ontvanger : <input type="text" name="naam_vriend"><br>
E-mailadres van de ontvanger : <input type="text" name="email_vriend">
<p>
Berichttekst:<br>
<textarea name="bericht" cols="60" rows="6">
Hallo, ik heb een email verstuurd vanaf deze pagina:
[a href=\"http://04025.06sc.thinkquest.nl\" target=\"_blank\"]http://04025.06sc.thinkquest.nl[/a]


Ik denk dat je deze pagina ook wel interessant zult vinden. Groetjes,
[typ je eigen naam]
</textarea><br>
<input type="submit" name="verzenden" value="Verstuur e-mail!">
</form>

<?php
}
?>

</body>
</html>

thank you so much in advance :D:D
yours sincerely,
Sjoerd

edit: some translations from dutch to english for your help :)
bericht=message
onderwerp=subject
bedankt_pagina= thanks page
onderwerp=subject that are about all important things.
Link to comment
Share on other sites

Not sure about embedding it....but if you create the link with the absolute path rather than just ecard1.jpg...so in other words

[a href=\"http://www.mydomain.com/myfolder/pictures/ecard1.jpg\" target=\"_blank\"]http://www.mydomain.com/myfolder/pictures/ecard1.jpg[/a]

it will work

Will
Link to comment
Share on other sites

[!--quoteo(post=351060:date=Mar 2 2006, 08:31 PM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Mar 2 2006, 08:31 PM) [snapback]351060[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Not sure about embedding it....but if you create the link with the absolute path rather than just ecard1.jpg...so in other words

[a href=\"http://www.mydomain.com/myfolder/pictures/ecard1.jpg\" target=\"_blank\"]http://www.mydomain.com/myfolder/pictures/ecard1.jpg[/a]

it will work

Will
[/quote]

the file is not even attached yet. what is the correct code for that and where to add it exactly. i am kind of lost big-time :D this is my first .php script ever so i have no real idea on how to do that either. this script took me 6 hours to find out :s if you could provide me with the piece of script on how to attach (and hopefuly embed), i would give you a virtual bottle of whisky :)
[a href=\"http://04025.06sc.thinkquest.nl/ecard1.jpg\" target=\"_blank\"]http://04025.06sc.thinkquest.nl/ecard1.jpg[/a] it is password protected though. i can supply that if it is really necessary , it will go public in a few days anyway :D

sjoerd
Link to comment
Share on other sites

I may be way of track here...but I am assuming that the mail you are sending is in HTML format. Is this correct?

If so you create the mail just like a page. In a page you only link to images...you do not embed them. If a email client can read HTML then it will link to the file and display it normally.

To add to your problem...you need to be sending both an HTML version and plain text for those of us who choose not to read HTML files and the others of us who have the Dfault settings in Outlook sett to remove all images.

Let me know a bit more about your process, goal etc and I will try to help

Will

Link to comment
Share on other sites

[!--quoteo(post=351071:date=Mar 2 2006, 08:47 PM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Mar 2 2006, 08:47 PM) [snapback]351071[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Let me know a bit more about your process, goal etc and I will try to help

Will
[/quote]

so far i am only sending a text file. i have no clue what so ever on how to send a html file :( The goal is for people to pick a ecard from a simple html table,linking to this page,where after entering some details like email and name,sends an ecard to the receiver. the image must be sent with it,on the way an image is displayed "inline"on a forum. As you said,i think it would indeed be the handiest to do in html-style email. I prefer to keep things simple,so that i myself can understand. I hope this is enough information for you ,to work with,otherwise, let me know :) im very new to php and also fairly new to computer forums :) (i am a long time meber on automotive forums though). i might not know all the termininology (sp?).

cya,

sjoerd

edit: specifically i am looking for the way how to attach images and how to embed them. give the code for it,and the way how to use them where in my file and i will be very grateful :)
Link to comment
Share on other sites

Again.,..if I undersand you...youcannot send an image in a plain text format.

However...I might be able to solve your problem.

I posted the solution for someone else.


Go To

[a href=\"http://www.phpfreaks.com/forums/imdex.php?showtopic75245&hl=\" target=\"_blank\"]http://www.phpfreaks.com/forums/imdex.php?showtopic75245&hl=[/a]

Read the full post. My solution is at the end...but by reading it all you will gain a greater understanding of the issues.

Will

Let me know how you get on
Link to comment
Share on other sites

[!--quoteo(post=351078:date=Mar 2 2006, 09:01 PM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Mar 2 2006, 09:01 PM) [snapback]351078[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Again.,..if I undersand you...youcannot send an image in a plain text format.

However...I might be able to solve your problem.

I posted the solution for someone else.
Go To

[a href=\"http://www.phpfreaks.com/forums/imdex.php?showtopic75245\" target=\"_blank\"]http://www.phpfreaks.com/forums/imdex.php?showtopic=75245[/a]

Read the full post. My solution is at the end...but by reading it all you will gain a greater understanding of the issues.

Will

Let me know how you get on
[/quote]

thank you. if i understand this corectly, i will have to write a new html page with the image in it.

where do i put the custom message entered then ? what code is used to do that :? should i put it in between the html file ? etcetera.
This is what i have so far:

<?php
$toemail= "$_POST["email_vriend"];
$subject = $_POST["eigennaam"] . " heeft je een e-card gestuurd";
$textversion .="Je hebt een bericht ontvangen van " . $_POST["eigennaam"] ;
$textversion .="(". $_POST["eigen_email"] ."). Hij schrijft het volgende: \n\n";
$textversion .= $_POST["bericht"];
$html=<<<HTML_OUTPUT

<html>
<body>
<img src="http://04025.06.sc.thinkquest.nl/ecard1.jpg"
<?php $_POST["bericht"]
?>
</body>
</html>


HTML_OUTPUT;

//Mail in TEXT and HTML with Headers

$headers = "From: xxx \r\n";
$headers .="Reply-to: xxx \r\n";
$headers. ="MIME-Version: 1.0\r\n";
$boundary = uniqid ("something");
$headers . ="Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .="This is a MIME encoded message. \r\n\r\n":
$headers .="--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" ."Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$textversion"));
$headers .="--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$html"));
mail($toemail, "$subject", "", $headers);
?>

now what should i enter as html output,is the link to the custom message ot "bericht"correct and is the other stuff correct ?

For now i will go to sleep. i will check back here tomorrow morning (early).
bye
sjoerd
Link to comment
Share on other sites

The custom message is entered how...by form?

If so you would simpoly collect that data and add it into the html page.

But be careful....

In HTML the process would be this

<? $custom_msg= $_POST['formfiled'];?>


<div class="message"><? echo $custom_msg;?></div> or something very similar.



However

in the >>>HTML_OUTPUT

it simply has to be

$custom_msg (where this value has already been set of course)

WHY??? well the <? PHP are already open in your .php document and you are simply telling the php processor that you have HTML output where as in a normal HTML page you have to open the <? tags to start the processor and then close tthe ?> to parse the rest as normal HTML


Will
Link to comment
Share on other sites

[!--quoteo(post=351092:date=Mar 2 2006, 09:35 PM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Mar 2 2006, 09:35 PM) [snapback]351092[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The custom message is entered how...by form?

If so you would simpoly collect that data and add it into the html page.

But be careful....

In HTML the process would be this

<? $custom_msg= $_POST['formfiled'];?>
<div class="message"><? echo $custom_msg;?></div> or something very similar.
However

in the >>>HTML_OUTPUT

it simply has to be

$custom_msg (where this value has already been set of course)

WHY??? well the <? PHP are already open in your .php document and you are simply telling the php processor that you have HTML output where as in a normal HTML page you have to open the <? tags to start the processor and then close tthe ?> to parse the rest as normal HTML
Will
[/quote]

i am so completely lost by now :s can you pls pls pls pls pls pls create that page for me. the html has to include :
Hello, "eigennaam" send you an ecard and the message using the "bericht" variable and the image,preferably embedded. i cant tell sh!t about this anymore. i think i have been staring at it for too long. allraeay 12-13 hours :(

i 'll buy you a virtual pint if you can do that for me :)

<?php
$toemail= "$_POST["email_vriend"];
$subject = $_POST["eigennaam"] . " heeft je een e-card gestuurd";
$textversion .="Je hebt een bericht ontvangen van " . $_POST["eigennaam"] ;
$textversion .="(". $_POST["eigen_email"] ."). Hij schrijft het volgende: \n\n";
$textversion .= $_POST["bericht"];
$html=<<<HTML_OUTPUT

<html>
<body>
<img src="http://04025.06.sc.thinkquest.nl/ecard1.jpg"
<? $bericht= $_POST['textversion'];?>
<div class="bericht"><? echo $bericht;?></div>
</body>
</html>



$headers = "From: $_POST["eigennaam"] \r\n";
$headers .="Reply-to: xxx \r\n";
$headers. ="MIME-Version: 1.0\r\n";
$boundary = uniqid ("ecard1");
$headers . ="Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .="This is a MIME encoded message. \r\n\r\n":
$headers .="--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" ."Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$textversion"));
$headers .="--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$html"));
mail($toemail, "$subject", "", $headers);
?>

<html>
<head>
<title>Voorbeeld 8.2 - vertel een vriend</title>
</head>
<body>
<h1>Verzend je e-card</h1>
Op deze pagina kun je de e-card bekijken op zijn volledige grootte en kun je hem bovendien versturen door enkele gegevens in te vullen.<p>
<a href="ecard1.jpg"><img src="ecard1.jpg"height=400"></a>
<hr>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
Je eigen naam : <input type="text" name="eigennaam"><br>
Je eigen e-mailadres :<input type="text" name="eigen_email"><br>
<hr>
Naam van de ontvanger : <input type="text" name="naam_vriend"><br>
E-mailadres van de ontvanger : <input type="text" name="email_vriend">
<p>
Berichttekst:<br>
<textarea name="bericht" cols="60" rows="6">
Hallo, ik heb een email verstuurd vanaf deze pagina:
[a href=\"http://04025.06sc.thinkquest.nl\" target=\"_blank\"]http://04025.06sc.thinkquest.nl[/a]


Ik denk dat je deze pagina ook wel interessant zult vinden. Groetjes,
[typ je eigen naam]
</textarea><br>
<input type="submit" name="verzenden" value="Verstuur e-mail!">
</form>

<?php
}
?>

</body>
</html>

this is what i have so far
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.