我已经创建了一个定制的php表单,并在提交时将电子邮件发送给用户,但我还想向管理员发送电子邮件,以便管理员使用wp\\U mail更新网站上表单提交的最新信息。
<form action="<?php echo get_permalink() ?>" method="post" enctype="multipart/form-data">
<input type="text" name="ch_name" placeholder="Name*" value="" required>
<input type="text" name="ch_phone_num" placeholder="Phone*" value="" required>
<input type="email" name="ch_email" placeholder="Email*" value="" required>
<input type="text" name="ch_company" placeholder="Company*" value="" required>
<input type="text" name="ch_job_title" placeholder="Job Title*" value="" required>
<input type="file" name="upload" value="">
<input type="submit" name="submit" id="submitted">
</form>
并对其进行处理:
if(isset($_POST[\'submit\'])) {
$ch_name = $_POST[\'ch_f_name\'];
$ch_phone_num = $_POST[\'ch_phone_num\'];
$ch_email = $_POST[\'ch_email\'];
$ch_company = $_POST[\'ch_company\'];
$ch_job_title = $_POST[\'ch_job_title\'];
$to = $ch_email;
$subject = "Thank you for job Submission ";
$content = "\'.$ch_name.\'";
$headers = \'MIME-Version: 1.0\' . "\\r\\n";
$headers .= \'Content-type: text/html; charset=iso-8859-1\' . "\\r\\n";
$headers .= \'From: Job Post at [email protected]\' .
wp_mail($to,$subject,$content,$headers);
}
最合适的回答,由SO网友:Krzysiek Dróżdż 整理而成
好的,那么您只需在同一位置为第二封电子邮件添加代码:
if ( isset( $_POST[\'submit\']) ) {
$ch_name = $_POST[\'ch_f_name\'];
$ch_phone_num = $_POST[\'ch_phone_num\'];
$ch_email = $_POST[\'ch_email\'];
$ch_company = $_POST[\'ch_company\'];
$ch_job_title = $_POST[\'ch_job_title\'];
$to = $ch_email;
$subject = "Thank you for job Submission ";
$content = "\'.$ch_name.\'";
$headers = \'MIME-Version: 1.0\' . "\\r\\n";
$headers .= \'Content-type: text/html; charset=iso-8859-1\' . "\\r\\n";
$headers .= \'From: Job Post at [email protected]\' . "\\r\\n";
wp_mail( $to, $subject, $content, $headers );
// And here goes second email:
$admin_email = get_option( \'admin_email\' );
$headers = \'From: Job Post at [email protected]\' . "\\r\\n";
wp_mail(
$admin_email,
\'Subject of second email\',
\'Message content\',
$headers
);
}