web email the graphics

This is a discussion on "web email the graphics" within the PHP Forum section. This forum, and the thread "web email the graphics are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 4th, 2007, 00:38
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
web email the graphics

Can I type html codes inside the textarea tag area and how can I insert a graphic or image or photo in the Mail Body area? Maybe it is stupid question for you guys, but any inputs will be much appreciated!!!

Here is the url:http://www.sandragreen.com/emailblast.php
Reply With Quote

  #2 (permalink)  
Old Oct 4th, 2007, 08:54
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: web email the graphics

Well, that's a loaded question if I ever heard one

You can certainly send HTML emails as well as embedded or attached images with PHP. You need to send your messages in MIME format.

The mail function in PHP sends plain text emails by default.

You need to send a bunch more email headers to create a MIME message.

A very simple example looks like this :

PHP: Select all



// define a boundary for the different parts of the message
    
$ob md5(time() . 'randomText');


   
$headers "From: someone@somewhere.com \n"

  
   
$headers .= 'Mime-Version: 1.0' "\n"// Let the email client know this is a Mime message
   
/**************
FOR SOME REASON the form won't submit with the following header included.
SEE THE IMAGE FOR THE MISSING HEADER LOL
************/


  // The message is broken into parts, part you add a new line, then '--' then the boundary then a new line :)
   
$message "You need to enable HTML Email to see the good parts of this message \n" '--' $ob "\n"// Deafult plain text/no mime support
   
   // This will be the plain text alternative for those with no html email
   
$message .= 'Content-Type: text/plain; charset=iso-8859-1' "\n";
   
$message .= 'Content-Transfer-Encoding: 7bit' "\n\n";
   
$message .= "This is the plaint text but the exciting stuff comes in the html part, enable HTML! \n" '--' $ob "\n";
  
  
// The HTML part of the email
   
$message .= 'Content-Type: text/html; charset=charset=iso-8859-1' "\n"// note the content type
   
$message .= 'Content-Transfer-Encoding: 7bit' "\n\n";
   
   
// finish the message with the boundary and then another '--' with no new line
   
$message .= "<title>Wow, HTML in Email!</title><body><b>Wow! Bold text in an email, worth it huh?</b></body> \n" '--' $ob '--';
   
      
mail('thisperson@theirdomain''Email Subject'$message$headers); // send mail like normal 
As you can no doubt see, there is quite a bit to it.

I found this tutorial from Sitepoint which is very good and explains from woe to go about PHP email.

With that said however, you can't go past the Mail class from PEAR. It takes most (in fact almost all) of the pain away for you via Object Abstraction

Mail class from PHP Extension and Application Repository

I hope that helps
Attached Images
File Type: jpg code.jpg (10.4 KB, 9 views)
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)

Last edited by Rakuli; Oct 4th, 2007 at 09:05. Reason: Something wrong with code, not accepting it.
Reply With Quote
  #3 (permalink)  
Old Oct 5th, 2007, 00:50
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: web email the graphics

Thanks Pal. That was very valuable tip. Much appreciated!!
Reply With Quote
  #4 (permalink)  
Old Oct 5th, 2007, 05:29
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: web email the graphics

Hi Rakuli, after reading that tutorial, testing it on my remote ISP server, I copied and pasted the html tags into the mail body textarea, I've received the html tags all over the place of the message, didn't interprete the html codes into normal look as the same as in the browser. I am getting confused! Can you please test it and pasted the html codes into the mail body area to see if you get the same problem or not. http://www.sandragreen.com/main.html,

Much appreciated!!
Reply With Quote
  #5 (permalink)  
Old Oct 5th, 2007, 05:35
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: web email the graphics

Hi Begeiste, that page you give cannot be found (I used the form from your first post, not sure if that is what you mean).

Do you have the code you're using, I might be able to see why you're not getting the HTML email.

Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #6 (permalink)  
Old Oct 5th, 2007, 21:37
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: web email the graphics

Sorry I was submitting the wrong name of the file. Can you test at this url : http://sandragreen.com/emailblast.php to your html code inside of mail body.

First can you insert your email at http://sandragreen.com/manage.php, after submitting the email will be added into the email table "subscribers". Then at http://sandragreen.com/emailblast.php, pasted your html code there to see if you receive the correct web page or whole lot of html tags in the email? In addition, the html email can be styled in the inline only or external attached styles?

Here is the emailblast.php code below:
PHP: Select all

<?php
if(isset($_POST['subject'])&&$_POST['subject']!=''){
    
//want to send form, so check for required fields
    
if(($_POST[subject] =="") || ($_POST[message] == "")){
        
header('Location: emailblast.php');
        exit;
    }
    
//connect to database
    
$conn mysql_connect('localhost','sandr10_charlton','777');
    if(!@
mysql_select_db('sandr10_photos')){
    exit(
'<p> Unable to locate the photos ''database at this time</p>');
}
    
    
//get emails from subscriber list
    
$sql 'select email from subscribers';
    
$result mysql_query($sql) or die(mysql_error());
    
    
//create a from: mailheader
    
$headers 'From: Your Mailing List <sg@sandragreen.com>';
    
$headers.= "Content-type: text/html; charset=windows-1256\n";
    
//loop through results and send mail
    
while($row mysql_fetch_array($result)){
        
set_time_limit(0);
        
$email $row['email'];
        
mail($emailstripslashes($_POST[subject]),stripslashes($_POST[message]), $headers);
        echo 
'newsletter sent to: '.$email.'<br>';
    }
} else { 
//haven't seen the form, so show it
?>
<html>
    <head>
    <title>Sending a Email blast</title>
    </head>
    <body>
    <h1>Send a News Letter</h1>
    <form method="post" action="<?php echo $_SERVER[PHP_SELF]; ?>">
        <p><b>Subject:</b><br>
        <input type="text" name="subject" size="30"></p>
        <p><b>Mail body:</b><br>
        <textarea name="message" cols="50" rows="10" wrap="virtual"></textarea>
        <p><input type="submit" name="submit" value="Send It"></p>
    </form>
    </body>
</html>
<?php ?>
Much appreciated your valuable tips!!!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP email form not sending email Kurt PHP Forum 1 Oct 12th, 2007 04:26
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
Graphics rbvinc Graphics and 3D 2 Sep 18th, 2006 13:20
Free Graphics site looking for link exchange with another graphics website! mgcom Link Building and Link Sales 6 Aug 19th, 2006 12:51


All times are GMT. The time now is 20:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43