Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29905

sending mail using php on localhost does not work. there are no errors. what could it be?

$
0
0

First of all i would like to say that i know there are a lot similar questions and i have seen a lot of them but unfortunately they could not help me.

so i am trying to have a automatic email reply.
here is what it looks like:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

$From = "example@gmail.com";
$to_email = "example2@gmail.com";
$subject = "Email Test PHP";
$message = "<h2>A tile</h2>";
$message .= "<p>first line.<p><br>";
$message .= "<p>second line.<p>";
$headers = "From: " . $From;

mail($to_email, $subject, $message, $headers)

i didn't get any error so i added this:

if (mail($to_email, $subject, $message, $headers)) {
    $msgBack = "Email successfully sent to <" . $to_email . ">";
    echo $msgBack;
    exit();
} else {
    $msgBack = "Email sending failed...";
    echo $msgBack;
    exit();
}

i don't get any errors but i always get Email sending failed... if i have overlooked something or am missing something i would appreciate any feedback !

if my question or explanation isn't optimal please tell me so i can improve !

btw: i have already seen this and tried it but to no avail.


Viewing all articles
Browse latest Browse all 29905

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>