Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP mail() error; I can't see for looking!
    primarykey
    data
    text
    <p>I'm having an issue with a simple PHP mailer. I've had this script working, but it now doesn't work and I can't see for the life of me why not. It's instead spitting out the raw HTML rather than the rendered template.</p> <p>If someone could have a browse and get back to me then that would be great. Thanks in advance.</p> <pre><code>&lt;?php if (isset($_POST['send'])) { // explode the email addresses $emails = explode(',', strtolower($_POST['to'])); // validate each email address foreach ($emails as $id =&gt; $email) { if (!filter_var(trim($email), FILTER_VALIDATE_EMAIL)) { die($email . ' is not a valid email address'); } } // all is good, let's send the emails out $subject = 'Digital Pop Christmas Email'; $message = file_get_contents('index.html'); // loop through each recipient foreach ($emails as $email) { $to = $email; $subject = 'Merry Christmas from Digital Pop'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'To: ' . $email . "\r\n"; $headers .= 'From: Digital Pop &lt;info@digitalpop.co.uk&gt;' . "\r\n"; if (mail($to, $subject, $message, $headers)) { echo "Email successfully sent to $email"; } else { echo "Error sending email to $email"; } echo "&lt;br /&gt;\r\n"; } exit; } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;PHP Mailer&lt;/title&gt; &lt;meta http-equiv="author" content="martin@digitalpop.co.uk" /&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Send the &lt;a href="./"&gt;Digital Pop Christmas Email&lt;/a&gt;.&lt;/p&gt; &lt;form action="?" method="post"&gt; &lt;fieldset&gt; &lt;div&gt;&lt;label for="to"&gt;To:&lt;/label&gt; &lt;small&gt;(separate email addresses with commas)&lt;/small&gt;&lt;/div&gt; &lt;div&gt;&lt;textarea name="to" id="to" cols="50" rows="8"&gt;&lt;/textarea&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="submit" name="send" value="Send" /&gt;&lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload