douluan1533 2019-03-23 18:44
浏览 30

PHP表单电子邮件 - 发送前等待x小时

I'm building a simple website where a form asks for an Artist Name, Email and a URL. Then, when the submit button is clicked, an email is sent to the "customer" with some details.

I want to give the effect that we are revising what he/she sent. For that I would need the email to be sent 30min/1h after the form was submitted. I haven't tried anything because I am pretty new with PHP and I couldn't find it anywhere else.

Here's my php:

<?php
if(isset($_POST['email'])) {

// EDIT THE BELOW TWO LINES AS REQUIRED
$email_to = "admin@domain.com";
$email_subject = "New repost submission, waiting for payment";

function errorMesg() {
    // Error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
}

// validation expected data exists
if(!isset($_POST['name']) ||
    !isset($_POST['email']) ||
    !isset($_POST['url'])) {
    errorMesg();       
}

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$url = $_POST['url']; // required

$email_message = "Pendiente de pago, detalles:

";

function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}

$email_message .= "Aritst: ".clean_string($name)."

";

$email_message .= "Email: ".clean_string($email_from)."

";

$email_message .= "Soundcloud Url: ".clean_string($url)."
";

// create email headers

$headers .= "From: Company <admin@website.com>
";
$headers .= "Reply-To: Company <admin@website.com>
";
$headers .= "Return-path: Company <admin@website.com>
";
$headers .= "Organization: Company
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-type: text/plain; charset=iso-8859-1
";
$headers .= "X-Priority: 3
";
$headers .= "X-Mailer: PHP". phpversion() ."
";

/* Prepare autoresponder subject */

$respond_subject = "Thank you for submitting your music!";

/* Prepare autoresponder message */

$respond_message = "Hey, thank you for your submission!

Your track has been revised and approved by our team and now you will be able to reach more than 8,000,000 fans!

If you would like us to proceed with the promotion of your Soundcloud track, simply fill out this form:

https://website.com/accepted

All tracks must be submitted via our website form due to strict quality regulations.

Company wants to provide its fans the best new music and we won't settle for anything less.

Best regards,

Company.

";
/* Send the response message using mail() function */

mail($email_from, $respond_subject, $respond_message, $headers);

/* Send the message using mail() function */

mail($email_to, $email_subject, $email_message, $headers);

//redirect to the 'thank you' page
header('Location: ./success.html');
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度