smtp.class.php
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
57
58
59
60
61
62
63
64
65
66
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
57
58
59
60
61
62
63
64
65
66
<?php
/*
SMTP mail class for php by daiman meijers
You can use this script if the php function mail() fails.
here can you send mails with the SMTP protocol.
gmail is a good smtp host for the smtp server and free.
*/
class smtp {
public $fp;
public $log;
public $nlijn;
public $logb;
public function sconnect($host, $port, $gebruiker, $wachtwoord, $timeout, $logb) {
$this->nlijn = "\r\n";
$this->fp = fsockopen($host, $port, $erstr, $erli, $timeout);
if (empty($this->fp)) {
echo exit("kon niet met de opgegeven host verbinden");
}
else {
$this->log["connect"] = fgets($this->fp, 515);
}
fputs($this->fp,"AUTH LOGIN" . $this->nlijn);
$this->log["auth"] = fgets($this->fp, 515);
fputs($this->fp, base64_encode($gebruiker) . $this->nlijn);
$this->log["usr"] = fgets($this->fp, 515);
fputs($this->fp, base64_encode($wachtwoord) . $this->nlijn);
$this->log["pass"] = fgets($this->fp, 515);
fputs($this->fp, "HELO localhost" . $this->nlijn);
$this->log["helo"] = fgets($this->fp, 515);
$this->logb = $logb;
}
public function smail($van, $vannaam, $aan, $aannaam, $bericht, $onderwerp) {
fputs($this->fp, "MAIL FROM: $van" . $this->nlijn);
$this->log["from"] = fgets($this->fp, 515);
fputs($this->fp, "RCPT TO: $aan" . $this->nlijn);
$this->log["to"] = fgets($this->fp, 515);
fputs($this->fp, "DATA" . $this->nlijn);
$this->log["data"] = fgets($this->fp, 515);
$headers = "MIME-Version: 1.0" . $this->nlijn;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $this->nlijn;
$headers .= "To: $aannaam <$aan>" . $this->nlijn;
$headers .= "From: $vannaam <$van>" . $this->nlijn;
$headers .= "Subject: $onderwerp" . $this->nlijn;
fputs($this->fp, "$headers\n\n$bericht\r\n.\r\n");
$this->log["head"] = fgets($this->fp, 515);
fputs($this->fp,"QUIT" . $nlijn);
$this->log["close"] = fgets($this->fp, 515);
if ($this->logb = 1) {
print_r($this->log);
}
}
}
?>
/*
SMTP mail class for php by daiman meijers
You can use this script if the php function mail() fails.
here can you send mails with the SMTP protocol.
gmail is a good smtp host for the smtp server and free.
*/
class smtp {
public $fp;
public $log;
public $nlijn;
public $logb;
public function sconnect($host, $port, $gebruiker, $wachtwoord, $timeout, $logb) {
$this->nlijn = "\r\n";
$this->fp = fsockopen($host, $port, $erstr, $erli, $timeout);
if (empty($this->fp)) {
echo exit("kon niet met de opgegeven host verbinden");
}
else {
$this->log["connect"] = fgets($this->fp, 515);
}
fputs($this->fp,"AUTH LOGIN" . $this->nlijn);
$this->log["auth"] = fgets($this->fp, 515);
fputs($this->fp, base64_encode($gebruiker) . $this->nlijn);
$this->log["usr"] = fgets($this->fp, 515);
fputs($this->fp, base64_encode($wachtwoord) . $this->nlijn);
$this->log["pass"] = fgets($this->fp, 515);
fputs($this->fp, "HELO localhost" . $this->nlijn);
$this->log["helo"] = fgets($this->fp, 515);
$this->logb = $logb;
}
public function smail($van, $vannaam, $aan, $aannaam, $bericht, $onderwerp) {
fputs($this->fp, "MAIL FROM: $van" . $this->nlijn);
$this->log["from"] = fgets($this->fp, 515);
fputs($this->fp, "RCPT TO: $aan" . $this->nlijn);
$this->log["to"] = fgets($this->fp, 515);
fputs($this->fp, "DATA" . $this->nlijn);
$this->log["data"] = fgets($this->fp, 515);
$headers = "MIME-Version: 1.0" . $this->nlijn;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $this->nlijn;
$headers .= "To: $aannaam <$aan>" . $this->nlijn;
$headers .= "From: $vannaam <$van>" . $this->nlijn;
$headers .= "Subject: $onderwerp" . $this->nlijn;
fputs($this->fp, "$headers\n\n$bericht\r\n.\r\n");
$this->log["head"] = fgets($this->fp, 515);
fputs($this->fp,"QUIT" . $nlijn);
$this->log["close"] = fgets($this->fp, 515);
if ($this->logb = 1) {
print_r($this->log);
}
}
}
?>