0

Okay guys. This is pretty weird. Basically, my mail function works, but when I delete the span element, the mail's not send anymore even tho it returns true. Why could that be?

So, this works:

$email = "mymail@gmail.com";
$to = $email;
$subject = "Mypage - Password recovery";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html' . "\r\n";
$headers .= 'From: mypage <mypage@mypage.com>' . "\r\n";

$message = "
<html>
    <head>
    <style>
    body{
        background: #fff;
        margin: 0;
        color: #fff;
        padding: 15px;
        padding: 0;
        font-size: 100%;    
    }
    a{
        text-decoration: none;
        color: inherit;
    }
    .subutton{
        padding: 10px;
        width: 50%;
        cursor: pointer;
        transition: all linear 0.20s;
        font-size: 150%;
        border-radius: 5px;
        border: 2px solid #3387d4;
        background: #fff;
        color: #000;
    }
    </style>
    </head>

    <body>
    <h1 style='color:#111;'>Hello</h1>
    <span style='color: #000;font-size: 125%;'>Click the link below to reset your password.</span>
    <p></p>
    <div class='subutton'>Reset password</div>
    <hr />
    <br />
    <span style='color: #aaa'>Life Trigger 2016</span>
    <p style='height: 500px;'></p>
    </body>
</html>
";
mail($to,$subject,$message,$headers);

And this doesn't:

$email = "mymail@gmail.com";
$to = $email;
$subject = "Mypage - Password recovery";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html' . "\r\n";
$headers .= 'From: mypage <mypage@mypage.com>' . "\r\n";

$message = "
<html>
    <head>
    <style>
    body{
        background: #fff;
        margin: 0;
        color: #fff;
        padding: 15px;
        padding: 0;
        font-size: 100%;    
    }
    a{
        text-decoration: none;
        color: inherit;
    }
    .subutton{
        padding: 10px;
        width: 50%;
        cursor: pointer;
        transition: all linear 0.20s;
        font-size: 150%;
        border-radius: 5px;
        border: 2px solid #3387d4;
        background: #fff;
        color: #000;
    }
    </style>
    </head>

    <body>
    <h1 style='color:#111;'>Hello</h1>
    <p></p>
    <div class='subutton'>Reset password</div>
    <hr />
    <br />
    <span style='color: #aaa'>Life Trigger 2016</span>
    <p style='height: 500px;'></p>
    </body>
</html>
";
mail($to,$subject,$message,$headers);

As soon as I delete the span the mail is not being sent anymore...

<span style='color: #000;font-size: 125%;'>Click the link below to reset your password.</span>

PS: My spam folder is empty and, it's not a spam issue.

Thanks.

EDIT

Fixing the bottom </span>

didn't solve the issue

EDIT 2

Now I noticed that it's not the span itself, because I tried to just remove the content of the span, and it stopped working... HOW THE HELL

Steven Dropper
  • 467
  • 3
  • 15

1 Answers1

0

You forgot to close the </span> tag here

<span style='color: #aaa'>Life Trigger 2016<span>.

Try this -

$email = "mymail@gmail.com";
$to = $email;
$subject = "Mypage - Password recovery";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html' . "\r\n";
$headers .= 'From: mypage <mypage@mypage.com>' . "\r\n";

$message = "
<html>
  <head>
  <style>
  body{
    background: #fff;
    margin: 0;
    color: #fff;
    padding: 15px;
    padding: 0;
    font-size: 100%;    
  }
  a{
    text-decoration: none;
    color: inherit;
  }
  .subutton{
    padding: 10px;
    width: 50%;
    cursor: pointer;
    transition: all linear 0.20s;
    font-size: 150%;
    border-radius: 5px;
    border: 2px solid #3387d4;
    background: #fff;
    color: #000;
  }
  </style>
  </head>

  <body>
  <h1 style='color:#111;'>Hello</h1>
  <p></p>
  <div class='subutton'>Reset password</div>
  <hr />
  <br />
  <span style='color: #aaa'>Life Trigger 2016</span>
  <p style='height: 500px;'></p>
  </body>
</html>
";
mail($to,$subject,$message,$headers);

Hope this will help you (y).

Got mail in spam

enter image description here

pradeep1991singh
  • 8,185
  • 4
  • 21
  • 31
  • @StevenDropper I tried above code and I can see mail in my gmail spam folder. But there is one thing i tried to send mail more than 3-4 times while i got only 2 mail in spam. Try to add email address to you contact list in mail box. – pradeep1991singh Nov 17 '16 at 20:25
  • I'm getting no spam no matter how many times I try to send the one that works, but well then, it must be a server side problem... duh... – Steven Dropper Nov 17 '16 at 20:50
  • Btw you got it in spam most likely because it's from mypage@mypage.com. my "from" address is different – Steven Dropper Nov 17 '16 at 20:51