hallo allemaal,
ik ben bezig met een script om e-mails automatisch op men website te laten zien nou heb ik hier wel het 1 en ander zien staan en gebruikt. Maar ik blijf toch wat fout doen want hij blijft aangeven dat de database het niet doet. Het is namelijk de bedoeling dat de tekst uit de email weergeven wordt op de website. Ik hoop dat iemand mij hiermee kan helpen.
Dit is mijn script:
<?
$mail_user_id = '[email protected]';
$mail_password = 'drumstel';
$host = 'localhost';
$database_name = 'sbssquad_test';
$database_username = 'sbssquad_test';
$database_password = 'noob';
$iso = 'd-m-Y H:i:s';
mysql_select_database($databse_name,mysql_connect($host,$databse_username,$database_password));
if($mbox = imap_open("{localhost:143}INBOX",$mail_user_id,$mail_password)) {
$mtnum = imap_num_msg($mbox);
if($mtnum > 0){
for($mnum = 1;$mnum <= $mtnum; $mnum++){
$mcontent = imap_fetchbody($mbox,$mnum,1);
$mheader = imap_headerinfo($mbox,$mnum)
$mheader->fromaddress = preg_replace("/<(.*?)\>/si", "", $mheader->fromaddress);
$mstructure = imap_fetchstructure($mbox,$mnum);
if($mstructure->subtype == 'MIXED') {
for($mpart = 1;!empty($mstructure->parts[$mpart]->dparameters[0]->value);$mpart++){
$mcontent = imap_fetchbody($mbox,$mnum,1);
$mheader = imap_headerinfo($mbox,$mnum);
$mheader->fromaddress = preg_replace("/<(.*?)\>/si", "", $mheader->fromaddress);
$mstructure = imap_fetchstructure($mbox,$mnum)
if($mstructure->subtype == 'MIXED') {
for($mpart = 1;!empty($mstructure->parts[$mpart]->dparameters[0]->value);$mpart
$mdata = imap_fetchbody($mbox,$mnum,$mpart + 1);
$mdecode = base64_decode($mdata);
$mimage = imagecreatefromstring($mdecode);
$mfilename = $mstructure->parts[$mpart]->dparameters[0]->value;
$mwidth = imagesx($mimage);
$mheigth = imagesy($mimage);
if($photow < $mwidth){
$mprop = $photow / $mwidth;
$mnewwidth = $photow;
$mnewheight = $mheigth * $mprop;
$mnewheight = round($mnewheight);
$mnewimage = imagecreatetruecolor($mnewwidth, $mnewheight);
imagecopyresampled($mnewimage, $mimage, 0, 0, 0, 0, $mnewwidth, $mnewheight, $mwidth, $mheigth);
if(file_exists('email/'.$mfilename)){
unlink('email/'.$mfilename); }
if(($mstructure->parts[$mpart]->subtype == 'txt')){
imagejpeg($mnewimage,'email/'.$mfilename);
if(($mstructure->parts[$mpart]->subtype == 'txt')
$mcontent.='*img]'.$domain.'email/'.$mfilename.'[/img]\n';
imagedestroy($mimage); }}
imap_close($mbox);
}
?>
En dit is mijn database file:
$sql = "INSERT INTO `".$prefix."weblog` (`subject`,`date`,`content`,`author`) VALUES ('".$mheader->subject."','".date($iso, strtotime($mheader->date))."','".onpost($mcontent)."','".$mheader->fromaddress."')";
mysql_query($sql);
1.113 views