using include in an email...

A

Anonymous

Guest
hey i have this php scipt after a form page..
Code:
<?
$email_from = "getinfo@happydogbehavior.com"; // Who the email is from
$email_subject = "Thankyou For Your Intrest In A Happy Dog Class"; // The Subject of the email
$email_txt = "
Hello $firstname, 
	Thankyou for submitting a form at www.happydogbehavior.com
We hope to see you and $dogsname in on of our Happy Dog Behavior And Training Classes Soon
			Ellen"; // Message that the email has in it
$email_to = "***********"; // Who the email is too
$headers = "From: ".'getinfo@happydogbehavior.com';
$ok = @mail($email_to, $email_subject, $email_txt, $headers);
?>
<?
$email_from = "Happy Dog Administrator"; // Who the email is from
$email_subject = "Someone Has Submitted Info"; // The Subject of the email
$email_txt = " 
	Hey Ellen, Someone has submitted a form on the get info page of the site.
	Here is their info.
	
	Name: $firstname $lastname
	Address: $address
	            $city , $state $zip
	Phone Number: $phonenumber1 - $phonenumber2 - $phonenumber3
	Email: $email
	Dogs Name: $dogsname
	Dogs Breed: $breed
	Dogs Age: $age
	
	Sincerely, Tom
	 
	"; // Message that the email has in it
$email_to = "$email"; // Who the email is too
$headers = "From: ".'getinfo@happydogbehavior.com';
$ok = @mail($email_to, $email_subject, $email_txt, $headers);
?>
<? include 'include.htm' ?>

that all works perfectly but i have a small image i want to include on the top of the email sent to the person.... heres the
image...
banner1.jpg

i tried using include but it would actually print include in the email.. how should i do this? thanks
 
Either you have to send an HTML e-mail (in which case the image is loaded from your site just like on a web page), or you have to send the image as an attachment. Google should give you some good tutorial links, but here's a good one to get you started.
 
yankees230230 said:
hey i have this php scipt after a form page..
Code:
<?
$email_from = "getinfo@happydogbehavior.com"; // Who the email is from
$email_subject = "Thankyou For Your Intrest In A Happy Dog Class"; // The Subject of the email
$email_txt = "
Hello $firstname, 
	Thankyou for submitting a form at www.happydogbehavior.com
We hope to see you and $dogsname in on of our Happy Dog Behavior And Training Classes Soon
			Ellen"; // Message that the email has in it
$email_to = "***********"; // Who the email is too
$headers = "From: ".'getinfo@happydogbehavior.com';
$ok = @mail($email_to, $email_subject, $email_txt, $headers);
?>
<?
$email_from = "Happy Dog Administrator"; // Who the email is from
$email_subject = "Someone Has Submitted Info"; // The Subject of the email
$email_txt = " 
	Hey Ellen, Someone has submitted a form on the get info page of the site.
	Here is their info.
	
	Name: $firstname $lastname
	Address: $address
	            $city , $state $zip
	Phone Number: $phonenumber1 - $phonenumber2 - $phonenumber3
	Email: $email
	Dogs Name: $dogsname
	Dogs Breed: $breed
	Dogs Age: $age
	
	Sincerely, Tom
	 
	"; // Message that the email has in it
$email_to = "$email"; // Who the email is too
$headers = "From: ".'getinfo@happydogbehavior.com';
$ok = @mail($email_to, $email_subject, $email_txt, $headers);
?>
<? include 'include.htm' ?>

that all works perfectly but i have a small image i want to include on the top of the email sent to the person.... heres the
image...
banner1.jpg

i tried using include but it would actually print include in the email.. how should i do this? thanks

in your $message_text
do insert
<html>
<body>
// get the text in here
<img src=""> //put the image link
</body>
</html>
 
than you sand like that you get message and simple string inside...
if you send like HTML all work propertly....
 
ruturajv said:
in your $message_text
do insert
<html>
<body>
// get the text in here
<img src=""> //put the image link
</body>
</html>

Actually, this isn't all you need to do. Some e-mail clients will display this as HTML-formatted, but many will just display the HTML. In order to make all e-mail clients display correctly (and to make clients that don't support HTML ignore it), you have to include headers that tell them that it's multipart, and which part is HTML and which is not (it's polite to include both an HTML-formatted version and a plaintext version). The tutorial which I linked to above explains most of this, but it might serve you better to just download a handy PHP class like this (registration is required, but if you don't already have a registration to PHPClasses.org anyway, you're seriously missing out) to do this for you.
 
Back
Top