I am writing a script to send birthday messages automatically to employees. For now I have taken hard-coded email ids. Now the problem is that these scripts are working perfectly well on my laptop Windows 10 Wampserver3.0.6. But now when I am transfering these files to the main desktop in the office(Windows 7 Wampserver3.1.3), the email sending based scripts crash the computer when you embed or attach an image. If I remove the attachment and send only the text, the email gets sent. But on attaching an image the computer crashes directly. The code is as follows:
require("PHPMailer-master\src\PHPMailer.php");
require("PHPMailer-master\src\SMTP.php");
require("PHPMailer-master\src\Exception.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->IsHTML(true);
$mail->Username = "abc@gmail.com";
$mail->Password = "********";
$mail->SetFrom("abc@gmail.com");
$mail->Subject = "Happy birthday!";
$mail->AddEmbeddedImage('compressed.jpg', 'compressed');
$mail->Body = "<h1>Happy Birthday!</h1><br>Have a wonderful day!";
$mail->AddAddress("abc@gmail.com","def@hotmail.com");
if(!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
I have tried so many things. I have increased the memory_limit
of wamp server.
An additional thing, debug=1 displays the process on chrome. So if i embed an image, it stops halfway, it does not display the process completely and crashes in the middle.
NOTE: addAttachment() works well but addEmbeddedImage() crashes the computer
It works perfectly well on my laptop. Please help.