Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2005, 06:57 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default mail()

Hi,

My question is: How can i send the html and image by mail using mail().
jpeg or any image file -> it has to be inline not a attachment.

also i want to use html in my mail message for sending a link to my customers.

I know how the mail function works but when i send the email the messege is empty.

my code is:
<form action="test2.php?act=submit" method="post">
    <input type="submit" value="Send" name="Submit">
</form>
<?php
$act = $_REQUEST['act'];

if($act == 'submit')
{
    $boundary = '-----=' . md5( uniqid ( rand() ) );

        $email = '[email protected]';
        $thefile = 'http://www.bestalternative.com/images/img/logo2.gif';
        $subject = 'from php';

        $message = "Content-Type: image/gif; name=\"my attachment\"\n";
        $message .= "Content-Transfer-Encoding: base64\n";
        $message .= "Content-Disposition: inline; filename=\"$theFile\"\n\n";

        $content_encode = chunk_split(base64_encode($content));
        $message .= $content_encode . "\n";
        $message .= "--" . $boundary . "\n";

    $headers = "From: \"Me\"<[email protected]>\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";

    // Additional headers
    $headers .= 'From: Mani Heravi <[email protected]>' . "\r\n";

        mail($email, $subject, $messege, $headers);
}
?>

Any idea.

Thanks
Regards
Mani_he

 
Old April 11th, 2005, 03:42 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi
I found the answer ;)
I will put my answer up for those people who may need it.

$email = '[email protected]';
$messege = '<img src="[put Image Path]"><br>';
$messege .= 'Please <a href="[Put Link Path">Click Here</a> To See Our Website.';
$subject = 'from php';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Type: multipart/mixed";


mail($email, $subject, $messege, $headers);

good luck






Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
problems sending mail with java mail gandacuboy J2EE 2 December 20th, 2006 03:05 PM
Sending e-mail to different mail box! Calibus Classic ASP Databases 4 September 3rd, 2004 05:48 PM
Sending both text mail and HTML mail - CDONTS madhukp Classic ASP Basics 1 October 8th, 2003 01:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.