Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
Jazzing up PHP Emails!

Posted by seandosh (seandosh), 29 October 2003
I have no problems mailing from a server using PHP but does anyone know how I can make the content more graphical i.e how to change the font adding images, links etc...

I figured if I wrote the body of the email using just plain old html MS Outlook and the like would pick up on this  but instead it just displayed the code in the body of the email.

I'm simply using the following code to send the email.

if (mail("$email",
      "$title",
      "$text",
     "From:email@email.co.uk")) {
     echo "<br>mail sent to ";
     echo $name;
     echo"<br><br><b>Thank you!</b>";
     } else {
     print "FAILURE!";

}

Is their another function I need to use? If anyone can shed any light on this i'd be very grateful!

Sean.

Posted by Custard (Custard), 29 October 2003
Hello,

Perhaps you need a Content-Type: text/html header in the mail.

Most of the HTML emails I've seen contain MIME entities, one of which is text (Content-Type: text/plain) and one of text/html.

I don't know php very well, but I'd start by looking for things to do with MIME.

hth

Bruce

Posted by John_Moylan (jfp), 30 October 2003
Pear can help here with Mail_mime.

This can send text, html and attachemnts.
I use this one on the command line.

Code:
#! /opt/php-4.3/bin/php

<?php

include('Mail.php');
include('Mail/mime.php');

$file = 'attach.txt';
$htmlFilename = "htmlFile.html";
$textFilename = "textFile.txt";

// html version
$FH = fopen ($htmlFilename, "r");
   $html = fread ($FH, filesize ($htmlFilename));
fclose ($FH);

// text version
$FH2 = fopen ($textFilename, "r");
   $text = fread ($FH2, filesize ($textFilename));
fclose ($FH2);

$crlf = "\r\n"; // lined endings
$hdrs = array('From'     => 'SENDER <me@this.com>',
             'Subject'  => 'Any old iron',
             'REPLY-TO' => 'reply@to_me.com');

$mime = new Mail_mime($crlf);

$mime->setHTMLBody($html);
$mime->setTXTBody($text);
$mime->addAttachment($file, 'text/plain');

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');

// Do a dblookup for emails here, or just make an array as I've done
$emailAry = array('this@that.com', 'that@this.com');

foreach ($emailAry as $address) {

   $mail->send($address, $hdrs, $body);
}
?>


jfp



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho