PHP表单电子邮件-等待x个小时,然后发送

时间:2019-03-23 18:44:23

标签: php phpmailer

我正在构建一个简单的网站,在该网站上,表格要求提供艺术家姓名,电子邮件和URL。然后,当单击“提交”按钮时,会将一封包含一些详细信息的电子邮件发送给“客户”。

我想表达的是,我们正在修改他/她发送的内容。为此,我需要在提交表单后30分钟/ 1小时发送电子邮件。我没有尝试过任何东西,因为我对PHP相当陌生,在其他任何地方都找不到。

这是我的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:\n\n";

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

$email_message .= "Aritst: ".clean_string($name)."\n\n";

$email_message .= "Email: ".clean_string($email_from)."\n\n";

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

// create email headers

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

/* 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 个答案:

没有答案