I'm trying to send a mail to a customers email thats set in my database.
$subject = 'Testing PHP Mail';
$txt = 'This mail is sent using the PHP mail function';
$headers = "FROM: test@gmail.com";
$query = ("SELECT email FROM ps_customer where id_customer = 2");
$result = $dbc->query($query);
$row = $result->fetch_assoc();
echo $row['email'];
$to_email = (string)$row;
//while ($row = $result->fetch_assoc()) {
// echo $row['email'];
// $to_email = (string)'$row <@>';
if (mail($to_email, $subject, $txt, $headers)) {
echo "send";
} else {
echo "failed";
}
this is my code that's need to send the email to the email out of the database.
but when i try to send it i get the error: : domain missing or malformed