Danial Danial - 1 year ago 63
PHP Question

mail funtion to not send blank emails and to send not blank emails in php

"If $email is empty then don't send email. done."
"If $email is not empty then send email. problem."

<?php if(isset($_POST["Submit"]))
$email = $_POST["emailaddress"]; }$to = "someone@example.com"; $subject = ""; $message = ""; $headers = "From: " .$email; if (isset($_POST["submit"]) && (!empty($email)))
$success = mail($to, $subject, $message, $headers); if ($success){
echo "<script>alert('Subscription Done! Please Stay tuned.')</script>"; }else{
echo "<script>alert('Email for Newsletter subscription was not successful.')</script>"; }
} ?>

Answer Source
Replace this edited code 

$from = "Danial@example.com";
$to = "someone@example.com";
$subject = "Hi,";
$message = "This mail is testing mail by $from";
if (isset($_POST["submit"]) && (!empty($email)))
    $success = mail($to, $subject, $message);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download