-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailtest.php
54 lines (44 loc) · 1.46 KB
/
mailtest.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
<?php
require("phpmailer/class.phpmailer.php");
$errors = '';
$myemail = '';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Virhe: täytä kaikki kentät\n";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$age = $_POST['age'];
$town = $_POST['town'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Virhe: sähköposti ei kelpaa\n";
}
if( empty($errors))
{
$mail = new PHPMailer();
$mail->CharSet = "utf8";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mailout.one.com"; // SMTP server
$mail->SMTPAuth = false;
$mail->SetFrom('mitaverkosto@askeleteenpain.fi', 'Mitä-verkosto');
//$mail->From = "'Mitä-verkosto' <mitaverkosto@askeleteenpain.fi>";
$mail->AddAddress("$email_address");
$mail->AddAddress('mitaverkosto@askeleteenpain.fi');
$mail->Subject = "Viesti, lähettäjä: $name, $age, $town";
$mail->Body = "Viesti otettu vastaan:\n"
."Nimi: $name \nSähköposti: $email_address \nIkä: $age \nPaikkakunta: $town \nViesti:\n $message";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
header('Location: http://askeleteenpain.fi/kiitos.php');
}
}
?>