我可以找到的代码中没有错误,并且我的本地 ssmpt 客户端已配置,我可以通过命令行发送邮件。但是根本没有邮件和错误来自php。就好像 php 从来没有命中这个本地邮件。我“确实”在我的 php.ini 中设置了我的 sendmail 路径并重新启动了 apache。我不知道还能是什么?
<?php
require_once('config.php');
$attrs = array(PDO::ATTR_PERSISTENT => true);
$pdo = new PDO("mysql:host=localhost;dbname=".$dbname, $db_username, $db_password, $attrs);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$custlist = $pdo->prepare("SELECT customer_list.sms_num, carriers.carrieraddr, customer_list.contact_first, customer_list.contact_last
FROM carriers, customer_list
WHERE send_id=send_code
ORDER BY customer_list.sms_num");
#$carrierlist = $pdo->prepare("SELECT * FROM carriers");
if (isset($_POST['body'], $custlist)) {
$custlist->execute();
#var_dump($custlist);
#var_dump($_POST['body']);
while ($row = $custlist->fetch(PDO::FETCH_ASSOC)) {
#$prefix = $row['sms_num'];
#$suffix = $row['carrieraddr'];
$to = 'brads@telecomm.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: admin@telecomm.com' . "\r\n" .
'Reply-To: admin@telecomm.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
#$body = $_POST['body'];
#var_dump($prefix);
#var_dump($suffix);
#var_dump($_POST['body']);
}
}
//$products = array();
$smscustobject = new ArrayObject($custlist);
#$smsarrayobject = new ArrayObject($carrierlist);
$pdo = null;
?>
<form action="" method="POST">
Your Message Body <input name="body" type="text" />
<input type="submit">
</form>