skip to Main Content
$thismessage=base64_encode($htmlmsg);
$subject="Grups Automation siemens and sick sensor Product";
$mail->SMTPDebug= 2;
$mail->IsSMTP();                                    //Sets Mailer to send message using SMTP
$mail->Host = 'My hosting server';                  //Sets the SMTP hosts of your Email hosting, this for Godaddy
$mail->Port = '465';                                //Sets the default SMTP server port
$mail->SMTPAuth = true;                             //Sets SMTP authentication. Utilizes the Username and Password variables
$mail->Username = '[email protected]';  //Sets SMTP username
$mail->Password = 'secret';                         //Sets SMTP password
$mail->SMTPSecure = 'ssl';                          //Sets connection prefix. Options are "", "ssl" or "tls"
$mail->setFrom ('[email protected]','Grups automation'); //Sets the From email address for the message
$mail->AddAddress($email_id);                       //Adds a "To" address
$mail->WordWrap = 50;                               //Sets word wrapping on the body of the message to a given number of characters
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $htmlmsg;

if ($mail->Send()) {
    echo 'Mail Sent';
    $sql = 'UPDATE `email_demo` SET `html_sub`="'.$subject.'", `html_body`="'.$thismessage.'",`sending_time`="'.time().'", `status` = "1" ,email_track_code="'. $track_code.'" WHERE `id` = "'.$id.'"';
    if (mysqli_query($con, $sql)) {
        echo 'Database updated successfully';
    } else {
        echo 'Error updating database: ' . mysqli_error($con);
    }
} else {
    echo "Mailer Error: " . $mail->ErrorInfo;
    echo 'There was an error';
}

This is my code and it is working for @gmail.com example : [email protected] but the same code is not working for domain specific email like [email protected]. And the email id getting from the database.

I want the solution that why this same code working for @gmail.com and not for other. Please tell the what the problem in the code and how to solve this

2

Answers


  1. try change from $mail->AddAddress($email_id); to $mail->AddAddress($email_id, '');

    Login or Signup to reply.
  2. As always, the first thing to do is read the error message, which says that the address you are trying to use is:

    [email protected] ,[email protected]
    

    which is obviously not a valid address. Check the data you are passing in, and also note that addAddress returns false if you try to use an invalid address; you don’t have to wait until calling send() to find out that it’s invalid.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search