E-mail script werkt niet
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:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?
$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);
}
?>
$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);
Link doet het niet.
Maakt niet uit. Ik krijg geen nameserver respons.
Parse error: parse error, unexpected T_VARIABLE in /home/sbssquad/domains/sbs-squad.com/public_html/martijn/e-mail/e-mail.php on line 16
Deze regel mist een ; aan het eind.
Parse error: parse error, unexpected T_VARIABLE, expecting ')' in /home/sbssquad/domains/sbs-squad.com/public_html/martijn/e-mail/e-mail.php on line 27
for($mpart = 1;!empty($mstructure->parts[$mpart]->dparameters[0]->value);$mpart
for($mpart = 1;!empty($mstructure->parts[$mpart]->dparameters[0]->value);$mpart
$mdata = imap_fetchbody($mbox,$mnum,$mpart + 1);
moet werken.
Het is op zijn minst handig om de commenting te laten zitten :/
Gewijzigd op 01/08/2005 16:15:00 door Eris -
Het werkt. Nu heb ik nog 1 laatste vraag hij geeft een error aan op de allerlaatste regel:
Parse error: parse error, unexpected $ in /home/sbssquad/domains/sbs-squad.com/public_html/martijn/email/e-mail.php on line 56
En dit is mijn script bijgewerkt:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?
error_reporting(E_ALL);
$mail_user_id = '[email protected]';
$mail_password = '*****';
$host = 'localhost';
$database_name = 'sbssquad_test';
$database_username = 'sbssquad_test';
$database_password = '*****';
$iso = 'd-m-Y H:i:s';
mysql_select_database($database_name,mysql_connect($host,$database_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/excists'.$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); }
$sql = "INSERT INTO `".$prefix."weblog` (`subject`,`date`,`content`,`author`) VALUES ('".$mheader->subject."','".date($iso, strtotime($mheader->date))."','".onpost($mcontent)."','".$mheader->fromaddress."')";
mysql_query($sql);
imap_delete($mbox,$mnum);
}
}
imap_expunge($mbox);
imap_close($mbox);
}
?>
error_reporting(E_ALL);
$mail_user_id = '[email protected]';
$mail_password = '*****';
$host = 'localhost';
$database_name = 'sbssquad_test';
$database_username = 'sbssquad_test';
$database_password = '*****';
$iso = 'd-m-Y H:i:s';
mysql_select_database($database_name,mysql_connect($host,$database_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/excists'.$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); }
$sql = "INSERT INTO `".$prefix."weblog` (`subject`,`date`,`content`,`author`) VALUES ('".$mheader->subject."','".date($iso, strtotime($mheader->date))."','".onpost($mcontent)."','".$mheader->fromaddress."')";
mysql_query($sql);
imap_delete($mbox,$mnum);
}
}
imap_expunge($mbox);
imap_close($mbox);
}
?>
Diverse { zijn niet afgesloten.