我不擅长PHP但仍尝试创建测试脚本以便我可以学习它。我指的是w3schools,我不知道我有多好或多坏。 我需要对刚刚创建的脚本进行一些更改。
<?php
$to = $_POST['EmailList'];
$subject = $_POST['EmailSubject'];
$message = $_POST['EmailBody'];
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <admin@admin.com>' . "\r\n";
mail($to,$subject,$message,$headers);
print_r($headers)
?>
<html>
<center>
<form method="post">
<br><strong>PHP Email Sender</strong><br><br><br>
Email List<br>
<textarea name="EmailList" placeholder="email@email.com (New Email Each Line)" rows="20" cols="50"></textarea><br><br>
Subject<br>
<input type="text" name="EmailSubject" placeholder="Your Subject Goes Here"><br><br>
Body<br>
<textarea name="EmailBody" placeholder="Write your content (HTML Accepted)" rows="20" cols="50"></textarea><br><br>
<input type="submit" value="Submit!">
</form><br><br>
</center>
</html>
如果可能,请告诉我。我只是需要一些帮助。
答案 0 :(得分:0)
经测试:
<?php
$subject = $_POST['EmailSubject'];
$message = $_POST['EmailBody'];
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <admin@admin.com>' . "\r\n";
$emailList = explode("\n",$_POST['EmailList']);
if(count($emailList) > 0){
foreach($emailList as $to){
$to = trim($to);
$sent = mail($to,$subject,$message,$headers);
if ($sent){
echo "<p>Sent: $to</p>";
}
else{
echo "<p>Not Sent: $to</p>";
}
}
}
else{
echo "<p>No email addresses</p>";
}
print_r($headers);
?>