-1

Hi I try to send mail to registred user.

This is my code :

   function email($to, $subject, $body, $from){
            require'PHPMailer-master/PHPMailerAutoload.php';

            define('GUSER', 'ivan.goricki99@gmail.com');
            define('GPWD', 'pass');

            $mail = new PHPMailer();  // create a new object
            $mail->IsSMTP(); // enable SMTP
            $mail->SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only
            $mail->SMTPAuth = true;  // authentication enabled
            $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
            $mail->Host = 'smtp.gmail.com';
            $mail->Port = 465; 
            $mail->Username = GUSER;  
            $mail->Password = GPWD;     
            $mail->SetFrom($from);
            $mail->Subject = $subject;
            $mail->Body = $body;
            $mail->AddAddress($to);
        }
function register_user($register_data){
        array_walk($register_data, 'array_sanitize');
        $register_data['password'] = md5($register_data['password']);
            $fields = '`' . implode ('`, `', array_keys($register_data)) . '`';
            $data = '\'' . implode('\',\'',$register_data) . '\'';
        mysql_query("INSERT INTO `users` ($fields) VALUES ($data)");
        email($register_data['email'],  'Aktivirajte svoj korisnički račun', "Zdravo".$register_data['username'].",\n\n da bi aktivirao svoj korisnički račun odi na dolje navedeni link:\n\n http://localhost/New%20folder%20(4)/index.php/activate.php?email=".$register_data['email']."&email_code=".$register_data['email_code']."\n\n CroVision");
    }

There is no errors in my code but still can't send mail.

Thanks

CroStorm
  • 3
  • 2

3 Answers3

1

I hope you are working on Linux. If that is the case, please check your /var/log/mail.log or /var/log/maillog depends on the linux distro. The issue can be the server is bouncing your email for different reassons.

Note: have you install sendmail or postfix?

If this is a windows environment, i am so sorry, i can't help you.

Good luck

Leandro Papasidero
  • 3,728
  • 1
  • 18
  • 33
0

change $mail->SMTPDebug = 0; to $mail->SMTPDebug = 1; so it will display you the errors.

Also confirm whether you are passing the variables as email address.

If you are with any hosting account, then sometimes there is a chance that you would not be able to send using SMTP.

If you are using localhost, try opening ssl in php.ini file. It might solve your problem if you dont see any error.

Alaksandar Jesus Gene
  • 6,523
  • 12
  • 52
  • 83
0

You do not supply any value for the $from parameter in the call to email()

mhall
  • 3,671
  • 3
  • 23
  • 35