我是构建php邮件的新手。我使用FROM ADDRESS,SENDER'S NAME,REPLY-TO,MESSAGE BODY和PASTE EMAIL(textarea)字段构建了表单。然而,问题在于脚本。我使用爆炸函数将PASTE EMAIL字段的值转换为数组。我使用array_walk函数,但我似乎没有得到正确的。我需要一个可以从这个数组中选择每个电子邮件地址并将消息副本发送给它的函数。 见下面我的脚本:使用复制粘贴电子邮件地址构建一个php邮件textarea
<?php
function function_to_be_applied($finaldest_email, $key){
require_once "Mail.php" ;
global $fromemail;
global $message;
global $fromname;
global $subject;
$to = $finaldest_email;
$from = "{$fromname} <$fromemail>";
$subject = $subject;
$host = "mail.mydomain.com";
$body = $message;
$smtp_username = "[email protected]";
$smtp_password = "password111";
$header = array('From' => $from, 'To'=>$to, 'Subject'=>$subject, 'replyTo'=> $replyto);
$smtp = Mail::factory('smtp', array('host'=>$host, 'auth'=> true, 'username'=> $smtp_username, 'password' => $smtp_password, 'port' => 2626));
$mail = $smtp->send($to, $header, $body);
if(PEAR::isError($mail)){return true;}else{return false;}
sleep($seconds);
}
//Output from the form
$seconds = $_POST['seconds'];
$subject = trim($_POST['subject']);
$fromname = trim($_POST['fromemail']);
$fromemail = trim($_POST['fromemail']);
$message = trim($_POST['message']);
$replyto = trim($_POST['replyto']);
$dest_email = trim($_POST['dest_email']);
$emailarray = explode("\r\n", $dest_email, 200);
$finaldest_email = array_unique($emailarray);
//using array_walk() function
if(true == array_walk($finaldest_email, 'function_to_be_applied')){
echo "Number of email sent: ".count($finaldest_email);
}
?>
我不包括这里的形式。如果有人能帮助我,我会很感激。
你有什么错误吗?快速查看表明,您不是在'function_to_be_applied()'中使用的所有东西,比如'$ replyto','$ seconds'等等。尝试添加它们,看看它是否有帮助。 – jprofitt
请考虑重新考虑您的代码。 – Flukey