Beste sd leden,
Ik heb nu een script wat gegevens inleest uit een imap mailbox.
Nu wil ik deze gegevens schrijven naar een database.
Maar de gegevens zijn dusdanig dat ik alleen het bericht en niet alle zooi eromheen in de database wil.
Iemand ervaring met dit soort praktijken?
- imap in php - Naar database schrijven?
-
12-02-2006, 16:03 #1
- Berichten
- 427
- Lid sinds
- 18 Jaar
imap in php - Naar database schrijven?
-
In de schijnwerper
Superdeal voor Linkbuilding! 100 artikelen normaal €25 per stuk, nu €9,99!Freelance / WerkErvaren tekstschrijvers tegen een scherp tarief! | +200 Positieve ReviewsFreelance / WerkVerhoog je online autoriteit met Publisher PlaceLinkpartnersGezocht: Haarden, Kachels en Verwarming linksLinkpartners -
12-02-2006, 19:02 #2
- Berichten
- 427
- Lid sinds
- 18 Jaar
Opgelost:
PHP Code:<?
include_once("config.php");
$mail_user_id = '';
$mail_password = "";
$iso = 'Y-m-d H:i:s';
if($mbox = imap_open("{localhost/pop3:110}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++){
$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('images/upload/'.$mfilename)){
unlink('images/upload/'.$mfilename);
}
if(($mstructure->parts[$mpart]->subtype == 'jpg') or ($mstructure->parts[$mpart]->subtype == 'jpeg')){
imagejpeg($mnewimage,'images/upload/'.$mfilename);
}else{
imagepng($mnewimage,'images/upload/'.$mfilename);
}
}else{
if(file_exists('images/upload/'.$mfilename)){
unlink('images/upload/'.$mfilename);
}
if(($mstructure->parts[$mpart]->subtype == 'jpg') or ($mstructure->parts[$mpart]->subtype == 'jpeg')){
imagejpeg($mimage,'images/upload/'.$mfilename);
}else{
imagepng($mimage,'images/upload/'.$mfilename);
}
}
$mcontent.='*img]'.$domain.'images/upload/'.$mfilename.'[/img]\n';
imagedestroy($mimage);
}
}
$sql = "INSERT INTO `mail` (onderwerp,date,content,author) VALUES ('".$mheader->subject."','".date($iso, strtotime($mheader->date))."','".$mcontent."','".$mheader->fromaddress."')";
mysql_query($sql) or die(mysql_error());
imap_delete($mbox,$mnum);
}
}
imap_expunge($mbox);
imap_close($mbox);
}
?>
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic