calmchess Posted April 16, 2009 Share Posted April 16, 2009 I'm useing this script to send mail which works fine my question is how do I send html and Images within the body of the email? <?php function sdmail(){ require_once ("../secure_php/Mail.php"); $recipients=$_POST['email']; //$from = $_POST[auth0]; $from = "[email protected]"; //$subject = $_POST[sub0]; $subject = "test"; $body = "test"; //$host = $_POST[host0]; $host = "smtp.somehost.net"; //$username = $_POST[user0]; $username = "calmchessplayer"; //$password = $_POST[pass0]; $password = "password"; $headers = array ('From' => $from, 'To' => $recipients, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($recipients, $headers, $body); } ?> Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/ Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 Which script are you using? If it doesn't support html emails then I've heard that phpmailer is very good. Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-811879 Share on other sites More sharing options...
calmchess Posted April 16, 2009 Author Share Posted April 16, 2009 I'm using pear mailer Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-811891 Share on other sites More sharing options...
calmchess Posted April 16, 2009 Author Share Posted April 16, 2009 i've been digging on the internet and i found some scripts for Mail_Mime but i can't seem to figure out where to get require "Mail/mime.php"; Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-811931 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 I've done a bit of digging too and as is often the case with PEAR the documentation seems to be lacking. If it is at all possible for you to switch to phpmailer there's plenty of examples here: http://phpmailer.codeworxtech.com/index.php?pg=examples including: http://phpmailer.codeworxtech.com/index.php?pg=exampleamail Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-811935 Share on other sites More sharing options...
calmchess Posted April 16, 2009 Author Share Posted April 16, 2009 I now can send html using the following script my problem is I want to send an image with the html and plain text ....I've googled it extensively but i can't find the solution.Could somebody help me with sending a half plain text and half html message.....An image too would be nice but not necessary. $message = new Mail_mime(); $text = "the html message is as follows."; $html = "<html></body><h1>this is an html test</h1></body></html>"; $message->setTxtBody($text); $message->setHTMLBody($html); $body = $message->get(); $extraheaders = array("From"=>$from, "Subject"=>$subject); $headers = $message->headers($extraheaders); Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-811997 Share on other sites More sharing options...
calmchess Posted April 17, 2009 Author Share Posted April 17, 2009 ok I have the image part working using the following script but I still need to know how to send part html and part plain text. $message = new Mail_mime(); $text = "the html message is as follows."; $message->setTxtBody($text); $message->addHTMLImage("../Images/atomic.gif","image/gif","atomic",true); $cid=$message->_html_images[count($message->_html_images)-1]['cid']; $html = '<html></body><h1>this is an html test</h1><img src="cid:'.$cid.'"></body></html>'; $message->setHTMLBody($html); $body = $message->get(); $extraheaders = array("From"=>$from, "Subject"=>$subject); $headers = $message->headers($extraheaders); Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-812018 Share on other sites More sharing options...
calmchess Posted April 17, 2009 Author Share Posted April 17, 2009 Nevermind forget the half html half plain text I'm just gonna be satisfied with having a html version with the plain text as backup as it is above. Link to comment https://forums.phpfreaks.com/topic/154408-mail-script-html-images-help/#findComment-812020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.