Mail function failure :(
Posted: Sat Apr 16, 2016 3:58 pm
So my problem lies in that it actually isn't sending the mail to my said emails (tried several different). Neither of the Mail() functions are working for me which tells me I've done something wrong.
I tried a different code and that worked but it didn't have the same stuff as I wanted nor was it in a seperate class.
So my code is as following:
The result I'm getting is:
Which is all correct aswell as the mail adress (real dommy adress)
And then I get at the bottom:
Mailet har blivit skickat.
Which translates into "Mail sent". Which is where I'm confused because here it get's checked or so I thought atleast as to if it was sent or not.
Is there something with the Mail() function i'm unaware of?
Thanks in advance,
Thomas
I tried a different code and that worked but it didn't have the same stuff as I wanted nor was it in a seperate class.
So my code is as following:
Code: Select all
public function contactForm(){
$msg = "";
$submit = isset($_POST['submit']) ? true : false;
if($submit){
$receiver = "dommyhelp@gmail.com"; //Jepla@telia.com
$sender = isset($_POST['name']) ? $_POST['name'] : null;
$email = isset($_POST['email']) ? $_POST['email'] : null;
$message = isset($_POST['text']) ? $_POST['text'] : null;
$subject1 = "Jepla.se";
$subject2 = "Kopia | Jepla.se";
$message1 = $sender ." skrev foljande:" ."\n\n" .$message;
$message2 = "Kopia av ditt medelande " .$sender ."\n\n" .$message;
$headers1 = "Från:" .$sender;
$headers2 = "Från:" .$receiver;
if (mail($receiver,$subject1,$message1,$headers1)){
mail($sender,$subject2,$message2,$headers2); // sends a copy of the message to the sender
$msg = "Mailet har blivit skickat."; //Success, Mail sent!
var_dump($receiver ." " .$subject1 ." " .$message1 ." " .$headers1);
}else{
$msg = "Mailet har inte skickats."; //Failure, Mail sadly not sent
}
}
$html = <<<EOD
<form id="ContactForm" method=post>
<fieldset>
<legend class="letter_spacing">Kontakt Formulär</legend>
<div>
<div class="wrapper">
<span>Namn:</span>
<input type="text" class="input"
placeholder="::Ditt namn, För och Efternamn" name="name">
</div>
<div class="wrapper">
<span>Email:</span>
<input type="text" class="input"
placeholder="::Din email adress"
name="email">
</div>
<div class="textarea_box">
<span>Meddelande:</span>
<textarea cols="1" rows="1"
placeholder="::Ditt Meddelande"
name="text"></textarea>
</div>
<input class="button" type="submit" value="Skicka" name="submit">
</div>
</fieldset>
</form>
{$msg}
EOD;
return $html;
}Code: Select all
string(89) "dommyhelp@gmail.com Jepla.se thomas lundqvist skrev foljande: dfsf Från:thomas lundqvist"And then I get at the bottom:
Mailet har blivit skickat.
Which translates into "Mail sent". Which is where I'm confused because here it get's checked or so I thought atleast as to if it was sent or not.
Code: Select all
if (mail($receiver,$subject1,$message1,$headers1)){
mail($sender,$subject2,$message2,$headers2); // sends a copy of the message to the sender
$msg = "Mailet har blivit skickat."; //Success, Mail sent!
var_dump($receiver ." " .$subject1 ." " .$message1 ." " .$headers1);
}Thanks in advance,
Thomas