0

I'm not sure what happen to my email code as i'm comparing with all the code i able to find online ... when i using localhost, it's work no problem.. and it having the txt file appear in mailoutput folder in xampp.

but when i request my friend to help host to web service.. it cannot work anymore for the code :(

below is my code. (modified from online source)

$subject = "Thanks for Registering." ;

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From : email' . "\r\n";

$message = "<html><body>
   <p> Thank you to register with Lecture Public Room Book Portal </p>
   <p> </p>
   <p> In order to activate your account please click the link below:</p>
   <p> <a href='link'>Verify Account</a> </p>
   <p></p>
   <p>Or you may go to the verification page using below link and paste in the verification code. Your verification code is $ver_code.</p>
   <p> <a href='link'> Verify page </a> </p>
   <p> </p>
   <p> Please do not reply to this email has the mailbox isn't monitored.</p>
   <p> </p>
   <p> </p>
   <p><center> - The Webmaster () - </center> </p>
   </body></html>";


if(mail($email, $subject, $message, $headers))
{
    $_SESSION['type'] = "User";
    echo ("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('Successful register. Please check your email for activate account.')
        window.location.href='index.php?user=$username#verify-slide';
                </SCRIPT>");
    exit();
}
else
{
    echo ("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('Please try again.')
        window.location.href='index.php?signup-slide';
        </SCRIPT>");
    exit();
} 

wish someone could please help me :(

Zeff Tang
  • 91
  • 9

3 Answers3

0

Maybe your hoster restricted access to php mail function. Email him about it. If so you can use Mandrill app.

Arsen Ibragimov
  • 425
  • 4
  • 18
  • ok, sorry i think i'm quite confuse with my own code now.. if my message didn't include the html tag.. and header only put email and not the html/text and so on.. it can be send from that server.. – Zeff Tang Apr 10 '14 at 14:08
0

Please check your error log if it returns some errors.

$headers .= 'From : email' . "\r\n";

Put your email in the email field ( preferably from the same domain email address )

A few bullet points (Assuming that mail() returns true and there are no errors in the error log) :

Does the sender address ("From") belong to a domain on your server? If not, make it so. Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a remote possibility with shared hosting.

Are mails filtered by a spam filter? Open an account with a freemailer that has a spam folder and find out. Also, try sending mail to an address without a spam filter. Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)

If you have access to log files, check those, of course, as suggested above.

Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.

from here

Community
  • 1
  • 1
Paul Bele
  • 1,514
  • 1
  • 11
  • 12
  • A From with a different host will still send the email, even if some mail servers will note it as spam. – naab Apr 10 '14 at 10:37
  • Of course, but i suggested that so that we can remove the possibility of the mail being marked as spam and not being seen – Paul Bele Apr 10 '14 at 10:39
  • ok, sorry i think i'm quite confuse with my own code now.. if my message didn't include the html tag.. and header only put email and not the html/text and so on.. it can be send from that server.. – Zeff Tang Apr 10 '14 at 14:00
0

In your current page email recipient is not set like this:

$subject = "Thanks for Registering." ;
$from = "admin@abc.com";
$email = "someone@gmail.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From :' . $from. "\r\n";
Neeraj Kumar
  • 506
  • 1
  • 8
  • 19