[英]PHP Mail script problems
这是我第一次使用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邮件脚本,因为它之前有一个(根据我正在构建此的朋友),我在内部测试时发生的错误是邮件正在发送但没有任何'$ formcontent'内容......只有标题(又名:From:,Job Number:,Completion Time :)
编辑编辑:如果它有助于这里是一个临时服务器,我现在就把它搞定(不要因为糟糕的网页设计而讨厌我......这是一项正在进行中的工作) http://temp.fullaf.com/cameron /rak/repeat.html
您的代码正在运行并发送电子邮件没有任何问题。
你可以在他们的网站上获得swiftmailer软件包 - > 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服务器的位置来测试这个特定的代码片段但是试试看。 如果有任何问题请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.