Reputation:
I am using basic php mail function to send an email. But due to unknown reason the is not being received. I am not able to find any issue with the code. Any help? thanks in advance.
PHP
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
?>
<?php
} else { // the user has submitted the form
// Check if the "from" input field is filled out
if (isset($_POST["contact_email"])) {
$from = $_POST["contact_email"]; // sender
$subject = $_POST["contact_name"];
$message = $_POST["contact_message"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// send mail
mail("[email protected]",$subject,$message,"From: $from\n");
echo "Thank you for sending us feedback";
}
}
?>
FORM
<form id="contactForm" class="cmxform" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" >
<strong>Usa il modulo sottostante per inviarci un messaggio email:</strong>
<div>
<label for="contact_name">Nome </label>
<em>(obbligatorio, almeno 2 lettere)</em><br />
<input id="contact_name" name="contact_name" size="30" class="required" minlength="2" value="" required="required" />
</div>
<div>
<label for="contact_email">E-Mail </label>
<em>(obbligatorio)</em><br />
<input id="contact_email" name="contact_email" size="30" type="email" class="required email" value="" />
</div>
<div>
<label for="contact_phone">Telefono </label>
<em>(opzionale)</em><br />
<input id="contact_phone" name="contact_phone" size="14" type="number" class="phone" value="" maxlength="14" />
<label for="contact_ext">interno </label>
<input id="contact_ext" name="contact_ext" size="5" type="tel" class="ext" value="" maxlength="5" />
</div>
<div>
<label for="contact_message">Il tuo commento </label>
<em>(obbligatorio)</em><br />
<textarea id="contact_message" name="contact_message" cols="70" rows="7" class="required"></textarea>
</div>
<div>
<input name="submit" class="submit" type="submit" value="Invia"/>
</div>
</form>
Upvotes: 0
Views: 84
Reputation: 540
PHP Mail returns boolean. True if message been sended by mailer, false - if not. (it not means that message has been recieved, only sended). try:
var_dump(mail("[email protected]",$subject,$message,"From: $from\n"));
Upvotes: 1