-1
我会通过在HTML页面上创建一个简单表单并将操作属性指向.php文件来测试此php脚本吗?我创建了.PHP文件,只是不知道如何发送它。如何测试PHP邮件功能而不邮寄到实际地址
<?php
$recipients = array('[email protected]','[email protected]',
'[email protected]',
'[email protected]',
); // i will be inserting the test email here
// Assigning data from the $_POST array to variables
$name = $_POST['sender_name'];
$mail_from = $_POST['sender_email'];
$mail_to = $_POST[$recipients];
$message = $_POST['sender_message'];
// Construct email subject
$subject = 'College Newsletter: ' . $name;
// Construct email body
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Message: ' . $message;
// Construct email headers
$headers = 'From: ' . $name . "\r\n";
$headers .= 'Reply-To: ' . $mail_from . "\r\n";
$mail_sent = mail(implode(',',$mail_to), $subject, $body_message, $headers);
?>
服务器似乎不喜欢我的内爆方法。 (见上文),我一直得到错误:警告:破灭()[function.implode]:在这样 传递的参数无效,我改变了PHP这样:
<?php
$to = array('[email protected]','[email protected]');
// specify your email here
// Assigning data from the $_POST array to variables
$name = $_POST['name'];
$mail_from = $_POST['mail'];
$message = $_POST['message'];
// Construct email subject
$subject = 'Breaking News: ' . $name;
// Construct email body
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Message: ' . $message;
// Construct email headers
$headers = 'From: ' . $name . "\r\n";
$headers .= 'Reply-To: ' . $mail_from . "\r\n";
mail($to, $name, $mail_from, $message, $headers);
?>
现在我得到的错误: 警告: mail()期望参数1是字符串,数组70中给出的数组bulk_mailer_test.php 任何人? -Cheers,-qs
邮寄自己??不知道你在这里想要什么 – 2014-10-01 19:39:08
所以,我需要做的只是一个表单的动作属性,指向.php文件? -Thanks -qs或者我需要安装WAMP或MAMP? -Sorry我是新来的服务器端。谢谢! – querystring 2014-10-01 19:41:34
是 - 对该文件的表单操作,适当命名的字段,method =“post”等,是的,如果您希望通过网络服务器运行您的php,则需要某种服务器。 – 2014-10-01 19:42:49