Deprecated: Function split() is deprecated in C:\xampp\htdocs\login_test\class.phpmailer.php on line 470
this error is coming from $mail->AddAddress(tester@hotmail.com); //is this same as To:

require_once('class.phpmailer.php');

                $mail = new PHPMailer();

                    $mail->AddAddress("test@hotmail.com"); //To:
                    $mail->Subject = "test1";

                    //html body
                    $body = "HEllow ikhlas";
                    $body .= "rest of boey";
                    $body .= "Sincerely,<br/>";
                    $body .= "test";

                    $mail->From = "test@hotmail.com";
                    $mail->FromName = "test";

                    if(!$mail->send())
                    {
                    echo "Mail error".$mail->ErrorInfo;
                    }
                    else
                    {
                    echo "worked";
                    }

What does the function AddAddress() in the PHPMailer class look like?

  /**
   * Adds a "To" address.
   * @param string $address
   * @param string $name
   * @return void
   */


  function AddAddress($address, $name = '') {
    $cur = count($this->to);
    $this->to[$cur][0] = trim($address);
    $this->to[$cur][1] = $name;
  }

  ...
  line 470.
      $toArr = split(',', $to);

4.1 just update to 5.2.0. (ops)

and how error is gone but i get this another error

Message body empty Mail error Message body empty

 if(!$mail->send())

is not working

Latest version is v5.2.0, you are using too older version which will not support latest PHP.

commented: works +0

just fix the body error.

know i get messaged worked

but when i the email is not there

just want to make sure.

$mail->From is the peron who is sending email
$mail->AddAddress is the person who is reserving the email.

Member Avatar for diafol

split - use explode() instead:

$toArr = explode(',', $to);

Becuse your email message body is not set, you can set it by:

$mail->IsHTML(true);
$mail->Body = $body;

split - use explode() instead:

$toArr = explode(',', $to);

i had a old verson. i just update to new verson.
also changed
$mail->IsHTML(true);
$mail->Body = $body;

just fixed all the errors. its all working fine. i get messeage saying worked.
but the email is not being sent.

If you are working in local system, you need SMTP settings to send email.

Either you can use SMTP credentials as shown here
OR you can use your own Gmail credentials as shown here

Member Avatar for diafol

Have you got an smtp server set up? If not turn Mercury Mail on (comes with XAMPP). You may need to configure it though.

Have you got an smtp server set up? If not turn Mercury Mail on (comes with XAMPP). You may need to configure it though.

i think i have it config. do you mean i have go to mercy->configuration->mercuryS smtp->connection control-uncheck 1st box.

If you are working in local system, you need SMTP settings to send email.
Either you can use SMTP credentials as shown here
OR you can use your own Gmail credentials as shown here

do you mean put these in my code?

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port       = 26;

if yes than, how do i find Host? and Port?

and i dont have a domain.

Once you go live and upload your site on live server it will send email as generally all server supports SMTP.
But if server is restricted, you have to give SMTP settings which will be given by your hosting providers.
Better if you have any live server, upload your test page on LIVE and then test.

ahh is there no way to do it without live pages?

Yes you can test in local, If you have gmail account you can do it as shown here

i have a gmail but do you know how can i find
$mail->host?
port number?

 $mail = new PHPMailer();
                    $mail->IsSMTP(); 
                    //$mail->Host = "test.gmail.com";
                    $mail->SMTPAuth = true;
                    $mail->SMTPSecure = "ssl";  //ssl or tls
                    $mail->Mailer = "smtp";
                    $mail->Host = "ssl://smtp.gmail.com";                           
                    $mail->Port = 465;              //set smtp port for the gmail
                    $mail->Username = "test@gmail.com";    //yourname@yourdomain
                    $mail->Password = "123456";     //password
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.