-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-trying-stuff.php
More file actions
executable file
·109 lines (91 loc) · 2.2 KB
/
page-trying-stuff.php
File metadata and controls
executable file
·109 lines (91 loc) · 2.2 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
// :-)
require_once "Mail.php";
require_once("Mail/mime.php");
$mois = 0;
$i = 0;
switch(date("n")) {
case 1:
$mois = "janvier";
break;
case 2:
$mois = "février";
break;
case 3:
$mois = "mars";
break;
case 4:
$mois = "avril";
break;
case 5:
$mois = "mai";
break;
case 6:
$mois = "juin";
break;
case 7:
$mois = "juillet";
break;
case 8:
$mois = "août";
break;
case 9:
$mois = "septembre";
break;
case 10:
$mois = "octobre";
break;
case 11:
$mois = "novembre";
break;
case 12:
$mois = "décembre";
break;
}
$from = "Trancendances <nepasrepondre@trancendances.fr>";
$reply_to = "Trancendances <contact@trancendances.fr>";
$subject = "Trancendances : Lettre d'information de ".$mois." ".date('Y');
//$body_html = "<strong>Test</strong>";
$body_html = file_get_contents("/var/www/trancendances-anchor/themes/Trancendances/template.htm");
$body_text = file_get_contents("/var/www/trancendances-anchor/themes/Trancendances/template.txt");
$mime_params = array(
'text_encoding' => '7bit',
'text_charset' => 'UTF-8',
'html_charset' => 'UTF-8',
'head_charset' => 'UTF-8'
);
$mime = new Mail_mime();
$mime->setTXTBody($body_text);
$mime->setHTMLBody($body_html);
$body = $mime->get($mime_params);
$dbh = new PDO('mysql:host=localhost;dbname=trancendances2', 'trancendances2', 'MJSH8ctxGAEdK3JX');
foreach($dbh->query("SELECT * FROM newsletter_emails_test") as $email) {
$host = "mail.ceypasbien.com";
$username = "nepasrepondre@trancendances.fr";
$password = "qyyYScWNTm";
$to = $email['email'];
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Reply-To' => $reply_to,
'MIME-Version' => '1.0',
// 'Content-Type' => 'multipart/alternative; boundary='.$boundary,
'Date' => date('D, j M Y G:i:s O')
);
$headers = $mime->headers($headers);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>
<p>E-mail address: $to</p>");
return 1;
} else {
$i++;
}
}
echo("<p>$i message(s) successfully sent.</p>");
?>