I have a PHP script in which it loops through a database extracting an email address from each record. This ultimately sends a formatted email to all the emails. The problem I'm having is that the message contains an image, however, the image is not showing up in the email. I have included the PHP script. The image on the server resides in a directory called "img".
Code:<?php // Database information is here $Email = $message = $success = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "Select email From wp_ig_contacts;"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row $myEmailAddress = "[email protected]"; $subject = "Weekly Devotional"; while($row = $result->fetch_assoc()) { $Email = $row["email"]; $nameErr = $name = ""; $whitelist = array('txtDevo'); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["txtDevo"])) { $nameErr = "Name is required"; } else { $name = $_POST["txtDevo"]; } $message = "<h3>WEEKLY DEVOTIONAL</h3>"; $message = $message . '<img src="GodsGlory2_r.jpg" style="margin-left: 30px">'; Here is the line in question $message = $message . '<br><br>'; $message = $message . '<p style="width: 55%; text-align: justified; margin-left: 40px">' . $name . '</p>'; $headers = "From: Dr. Branson" . "<" . $myEmailAddress . ">" . "\r\n"; $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($Email, $subject, $message, $headers)) { $success = true; } else { echo("Message failure!"); } } } if ($success = true) { echo("<script>alert('Message sent successfully!');</script>"); } } else { echo "0 results"; } $conn->close(); ?>




Reply With Quote