core php mail function without phpmailer

Solutions on MaxInterview for core php mail function without phpmailer by the best coders in the world

showing results for - "core php mail function without phpmailer"
Ema
06 May 2020
1<?php
2ini_set('display_errors',1);
3ini_set('display_startup_errors',1);
4error_reporting(-1);
5
6session_start();
7
8$to = 'toSenderEmail@xxxxx.xxxxx';
9$subject = 'Subject xxxxx xxxxxx';
10
11$headers = "MIME-Version: 1.0\r\n";
12$headers .= "Content-Type: text/html; charset=charset=utf-8\r\n";
13$headers .= "From: " . $_POST['email'] . "\r\n";
14//$headers .= "Reply-To: ". $_POST['email'] . "\r\n";
15$headers .= "CC: xxx@xxxxx.xxx\r\n";
16
17
18
19$message = "<html><body>";
20
21$message .= '<table style="border-color: #666; background: #eee; cellpadding="10">';
22$message .= "<tr><td><strong>Name:</strong> </td><td>" . $_POST['username'] . "</td></tr>";
23$message .= "<tr><td><strong>Email:</strong> </td><td>" . $_POST['email'] . "</td></tr>"; 
24
25
26$message .= "</table>";
27$message .= "</body></html>";
28
29
30echo $message;
31//echo $headers;
32
33
34
35$response=mail($to, $subject, $message, $headers);
36
37if($response==1)
38{
39echo "<script language='javascript' type='text/javascript'>
40        
41       window.location = 'index.html';
42    </script>";
43
44}
45else{
46echo 
47"<script language='javascript' type='text/javascript'>
48        alert('mail send failed');
49    </script>";
50}
51
52
53
54?>