0

I cant get this piece of code to work I know how to use the mail part of PHP and cant understand what is wrong with.

##Send activation Email

$to      =  $_POST['email'];

$subject = " YOURWEBSITE.com Registration";

$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link:\rhttp://www.YOURWEBSITE.com/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ YOURWEBSITE.com Team";

$headers = 'From: noreply@close2.me';


mail($to, $subject, $message, $headers);
maxgee
  • 157
  • 1
  • 4
  • 13
  • What is the error? Or, what is not working? – janenz00 Oct 16 '12 at 02:56
  • @janenz00 It wont send the email. – maxgee Oct 16 '12 at 02:57
  • mail() function is quite hard to debug (only return true or false), is it possible a server setting issue? On Linux, usually you can check the log at /var/log/messages – Pandaski Oct 16 '12 at 03:11
  • It is not possible to send on localhost, you need to host it online to work. If you want to send, you will required to install something in order to work it well.... – Furry Oct 16 '12 at 03:15
  • don't use mail(). it's useless garbage. use a proper mail package like PHPMailer or Swiftmailer which at least give you useful diagnostics if something's failing at the PHP level. – Marc B Oct 16 '12 at 03:47
  • Post your sample $activationKey – Vijay Joseph Oct 16 '12 at 04:59

1 Answers1

0

look below tutorials

http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm

http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

http://php.net/manual/en/function.mail.php

sending mail using smtp authentication is one of the solution or you can use mail libraries like swift mailer

Sivagopal Manpragada
  • 1,554
  • 13
  • 33