这是我第一次使用PHP而且我在实现所有内容的邮件形式时遇到了麻烦,我似乎无法实现这一点。下面是我的代码,如果有人可以指出我在调试方面的正确方向,我将非常感激。
<?php
$job_number = $_POST['job_number'];
$completion_time = $_POST['completion_time'];
$email = $_POST['email'];
$formcontent = "From: $email \n \n Job Number: $job_number \n \n Completion Time: $completion_time \n";
$recipient = "data@rak.co.uk";
$subject = "Repeat Order";
$mailheader = "From: $email \r\n";
mail(
$recipient,
$subject,
$formcontent,
$mailheader
)
or die(
"
Error!
"
);
echo( "
<div style='font-size:24px; margin-top: 100px; text-align: center;'>
Thank You!
"
. " - " .
" <a href='home.html' style='color: #1ca03e;'>
Return Home
</a>
</div>
"
);
?>
谢谢你, 卡梅伦
编辑:更多信息,服务器支持PHP邮件脚本,因为它之前有一个(根据朋友我建立这个),我在内部测试时遇到的错误是邮件正在发送,但没有任何&#39; $ formcontent&#39; content ...只有标题(又名:From:,Job Number:,Completion Time:)
编辑编辑:如果它有助于这是一个临时服务器,我现在就把它搞砸了(不要因为糟糕的网页设计而讨厌我......它正在进行中){{3 }}
答案 0 :(得分:1)
您的代码正在运行并发送电子邮件,没有任何问题。
答案 1 :(得分:1)
您可以在此处获取其网站上的swiftmailer软件包 - &gt; http://swiftmailer.org/
require_once 'swiftmailer/lib/swift_required.php';
function new_mail($subject, $content, $recipients, $from)
{
// Create the message
$message = Swift_Message::newInstance();
// Give the message a subject
$message->setSubject($subject);
// Set the From address with an associative array
$message->setFrom($from);
// Set the To addresses with an associative array
$message->setTo($recipients);
// Give it a body
$message->setBody($content);
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
}
$job_number = $_POST['job_number'];
$completion_time = $_POST['completion_time'];
$email = $_POST['email'];
$message = "From: $email \n \n Job Number: $job_number \n \n Completion Time: $completion_time \n";
$recipients = array('data@rak.co.uk' => 'Your name of choice');
$subject = "Repeat Order";
$from = array($email => 'Name of choice.');
new_mail($subject, $message, $recipients, $from);
我目前不在我可以访问ftp服务器的位置来测试这个特定的代码片段但是尝试一下。如果有任何问题请告诉我。