forked from DSAndreee/form-to-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
50 lines (40 loc) · 1.08 KB
/
send.php
File metadata and controls
50 lines (40 loc) · 1.08 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
<?php
function telegram($mail, $subject, $message){
$key = "botXXXXXXXXX:AABBCCDDEEFFGGHHIIJJKKLLMMNNOO";
$chat_id = "123456789";
if(isset($mail) && isset($subject) && isset($message)){
$ch = curl_init("https://api.telegram.org/".
$key."/sendMessage?chat_id=".
$chat_id."&text=De : ".
$mail."%0aSujet : ".
$subject."%0a%0aMessage : %0a".
$message);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
}
}
$mail = $_POST['mail'];
$subject = $_POST['subject'];
$message = $_POST['message'];
telegram($mail, $subject, $message);
?>
<!DOCTYPE html>
<html>
<head>
<title>Blog — Telegram</title>
</head>
<body>
<h1>Formulaire vers Telegram</h1>
<form method="POST" action="">
<label for="mail">E-mail</label><br/>
<input type="text" name="mail"><br/>
<label for="subject">Sujet</label><br/>
<input type="text" name="subject"><br/>
<label for="message">Message</label><br/>
<input type="text" name="message"/><br/>
<input type="submit" name="Envoyer le message">
</form>
</body>
</html>