Mail - only send to Bcc
| From: | Alexander Petri | Date: | Fri, 22 Apr 2005 10:46:30 +0000 |
| Subject: | Mail - only send to Bcc | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-18910@lists.php.net to get a copy of this message | ||
Hi
i tried the following code send mails only toBccs
but they are all in the 'To' header
how could i set them in 'Bcc' ?
what about "nonworking" emailadresses in a large array
are there any expiriences
here is my code:
define(LANG,"de");
require_once '../ini/config.php';
$headers['Subject'] = "Text in der Betreffzeile";
$headers['From'] = "info@my-domain.de";
$headers['Bcc'] = array( "jon.doe@gmx.de",
"test@test.de",
"de@de.de",
"bla@blubb.com");
// text
$text = "asdasd asdasd adsasd \n";
$text.= "Link klicken: \n\n";
$text.= 'http://www.gmx.de';
if(sendMail($text,$headers)){
echo "Mailing hat geklappt";
}else{
echo "Mailing fehlgeschlagen";
}
// sendmail fkt
function sendMail($text,$hdrs,$crlf="\n"){
require_once('Mail.php');
require_once('Mail/mime.php');
$html = parseHtml($text);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
return $mail->send($hdrs['Bcc'], $hdrs, $body);
}
//HTML Parse fkt
function parseHtml($text){
$pre="<span style=\"font-family:Arial, Helvetica, sans-serif \">";
$suff="</span>";
$text_arr = explode (" ", $text);
foreach($text_arr as $k => $v){
if(substr_count($v,"http://")==1){
$text_arr[$k]='<a href="'.$v.'"
>'.$v.'</a><br>';
}else{
$text_arr[$k]=nl2br($v);
}
}
$text = $pre.implode(" ", $text_arr).$suff;
return $text;
}