Reputation: 1
I upload the PHP script to two different domains, but the A domain/server is not working and the B domain/server is able to receive the email message. Someone says that it may be the server setting issue, and someone says that is the script issue. Can anyone help or must use the STMP format only able to work on a certain domain? How to use STMP as I still new in PHP.
<?php
if ($_GET) {
$Name = $_GET['Name'];
$Email = $_GET['Email'];
$Phone = $_GET['phonefull'] . $_GET['Phone'];
$Message = $_GET['Message'];
$Country = $_GET['country'];
$Departmnet = $_GET['Department'];
$PreferedDate = $_GET['PreferedDate'];
$DOB = $_GET['dob'];
$PreferedTime = $_GET['PreferedTime'];
$mine_email = "[email protected]";
if ($_GET['Department'] == 'imaging') {
$to = "[email protected]";
} elseif ($_GET['Department'] == 'Wellness') {
$to = "[email protected]";
} elseif ($_GET['Department'] == 'Aesthetics') {
$to = "[email protected]";
}
$subject = "For Appoinment";
$message = '<html><body>';
$message .= "<table border='1px'>
<thead>
<th>Name</th>
<th>Phone</th>
<th>Country</th>
<th>DOB</th>
<th>Email</th>
<th>Department</th>
<th>Preferred Date</th>
<th>Preferred Time</th>
</thead>
<tbody>
<tr>
<td>" . $Name . " </td>
<td>" . $Phone . "</td>
<td>" . $Country . "</td>
<td>" . $DOB . "</td>
<td>" . $Email . "</td>
<td>" . $Departmnet . "</td>
<td>" . $PreferedDate . "</td>
<td>" . $PreferedTime . "</td>
</tr>
<tr>
<th colspan='8'> Message </th>
</tr>
<tr>
<td colspan='8'> " . $Message . "</td>
</tr>
</tbody>
</table>";
$message .= '</body></html>';
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$retval = mail($to, $subject, $message, $headers);
if ($retval == true) {
?>
<script>
localStorage.setItem("mailsend", "true");
window.location = "../index.html";
</script>
<?php
} else {
echo "Message could not be sent...";
}
}
?>
Upvotes: 0
Views: 37
Reputation: 1503
A mail sending issue can be a server issue or php script issue as you said. But for sure you can debug them.
If you are new and want to send emails, then I would suggest using any Mail Libraries in PHP.
PHPMailer is one such library for sending emails and make them less painful. The link is given below. PHPMailer
If you are using SMTP for sending emails then you should verify the ports (Eg: 25, 465 etc) are open depending upon the protocol you are using. And I would suggest always using some Fake SMTP Server for testing. Mailtrap can do that job for you. Link to Mail Trap: MailTrap.
I hope these 2 should do the job for you.
Upvotes: 1