You are here: Re: PHP Mail() and versions « All PHP « IT news, forums, messages
Re: PHP Mail() and versions

Posted by Steve on 02/25/07 18:12

"cover" <coverlandNOSPAM914@yahoo.com> wrote in message
news:bmc3u2li9n0p9m1oovlbnuf1nvbkj13dif@4ax.com...
| On 23 Feb 2007 22:07:55 -0800, "Martin Mandl - m2m tech support"
| <martin.mandl@gmail.com> wrote:
|
| >Dear Cover,
| >
| >mail() exists much longer than 4.1. Only thing which changed in 4.3 is
| >the support for smtp_port. Have a look at the manual:
| >
| >http://at.php.net/manual/en/ref.mail.php
| >
| >It's more likely that your operating system is the problem, what are
| >you using? Is the path to sendmail configured correctly? Do you have
| >sendmail at all? Etc....
| >
| >Good luck
| >
| > Martin
|
| Thanks Martin, I'm using XP on both machines and to be honest with
| you, I'm not real familiar with 'sendmail'. Having read references to
| it in various code snips but haven't read anything comprehensive
| enough to help me understand what it is and where it is. I.e. I
| haven't located a subfolder for 'sendmail' or a sendmail.exe file for
| example.

here's what i use. it works either on linux or on windows (iis included).
here's how you'd call it:
(note that your drop directory would be c:/inetpub/mailroot/pickup/ ...
also, remove the last argument - it is using sendmail in this case)

email::send(
$site->adminEmail ,
$site->adminEmail ,
'' ,
'' ,
$site->title . ' - Security Alert' ,
'' ,
$html ,
$site->title ,
$site->rootDirectory . 'images/email.logo.jpg' ,
$site->mailDropDirectory ,
'/usr/sbin/sendmail -ti < '
);


and here's the actual class...sends either plain text and/or html:
(you can add attachments to emails with *slight* modification and, notice
that the company logo *is* an attachment...you'd just add another argument,
encode the file(s) to be attached, and add another boundry for each...no
big.)

hth.

<?
class email
{
static function send(
$to ,
$from ,
$cc = '' ,
$bcc = '' ,
$subject ,
$text = '' ,
$html = '' ,
$companyName = '' ,
$logo = null ,
$dropDirectory = '' ,
$exec = '' ,
$execOptions = ''
)
{
$messageHtml = $html;
$html = '
<html>
<style>
body
{
background-color : white;
color : black;
font-family : verdana, tahoma, arial, times new
roman, sans-serif;
font-size : 8pt;
margin : 0px;
text-align : left;
}
</style>
<body>
';
if (isset($logo))
{
$image = file_get_contents($logo);
$image = chunk_split(base64_encode($image));
$html .= '
<img alt="' . $companyName . '" border="0px"
src="cid:logo" style="float:right;">
<br>
<br>
<br>
<br clear="all">
';
}
if ($messageHtml == ''){ $messageHtml = '<html><body>' . $text; }
$html .= $messageHtml . '</body></html>';
if ($text == ''){ $text = $html; }
$boundry = '----=' . md5(uniqid(rand()));
$related = '----=' . md5(uniqid(rand()));
$mail = "MIME-Version: 1.0\r\n";
$mail .= "TO: " . $to . "\r\n";
$mail .= "FROM: " . $from . "\r\n";
$mail .= "CC: " . $cc . "\r\n";
$mail .= "BCC: " . $bcc . "\r\n";
$mail .= "Subject: " . $subject . "\r\n";
$mail .= "Content-Type: multipart/related;
boundary=\"$related\"\r\n\r\n\r\n";
$mail .= "--$related\r\n";
$mail .= "Content-Type: multipart/alternative;
boundary=\"$boundry\"\r\n\r\n\r\n";
$mail .= "--$boundry\r\n";
$mail .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$mail .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$mail .= $text . "\r\n\r\n";
$mail .= "--$boundry\r\n";
$mail .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$mail .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$mail .= $html . "\r\n\r\n";
$mail .= "--$boundry--\r\n\r\n";
$mail .= "--$related\r\n";
$mail .= "Content-Type: image/jpeg\r\n";
$mail .= "Content-ID: logo\r\n";
$mail .= "Content-Disposition: attachment;
filename=\"logo.jpg\"\r\n";
$mail .= "Content-Transfer-Encoding: base64\r\n\r\n";
$mail .= $image . "\r\n\r\n";
$mail .= "--$related--\r\n\r\n";
$mail .= "-- End --\r\n";
$fileName = $dropDirectory . strtoupper(md5(uniqid(rand()))) . '.eml';
file_put_contents($fileName, $mail);
if (!$exec){ return $mail; }
exec($exec . $fileName . $execOptions);
@unlink($fileName);
return $mail;
}
}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация