0

我正在尝试制作一个告诉朋友类型的脚本,其中一个人填写姓名和朋友姓名,当他们单击发送时,将向朋友发送一封电子邮件,显示正在举行的活动的图片.

HTML:

<form name=refer action="refer.php" method="POST">
<td align="center" valign="middle"><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" colspan="2"><strong>Your Details</strong></td>
</tr>
<tr>
<td height="30">Name:
<input name="fromName" type="text" id="fromName"></td>
<td height="30">E-Mail:
<input name="fromEmail" type="text" id="fromEmail"></td>
</tr>
<tr>
<td height="30" colspan="2"><strong>Friends Details</strong></td>
</tr>
<tr>
<td height="30">Name:
<input name="toName" type="text" id="toName"></td>
<td height="30">E-Mail:
<input name="toEmail" type="text" id="toEmail"></td>
</tr>
<tr align="center">
<td height="30" colspan="2"><input type="submit" name="Submit" value="Refer"></td>
</tr>
</table></td></form>

PHP:

<?php
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
if ($fromEmail)
{
$ref=getenv('HTTP_REFERER');
if ($fromName=='')
$subject= "Your friend has referred you this link from www.sitename.com";
else
$subject= "$fromName has referred you this link from www.sitename.com";
$message = "
Dear $toName,
Your friend $fromName has referred this link to you.
Please visit this link by clicking $ref
";
$from = "From: $fromEmail\r\n";
mail($toEmail, $subject, $message, $from);
header ("location:".$ref);
}
?>
4

2 回答 2

0
    $message = 'Dear '.$toName.',
    Your friend '.$fromName.' has referred this link to you.
    Please visit this link by clicking '.$ref.'. 
    Here is an image of the event: <img src="https://www.google.com/images/srpr/logo4w.png" alt="" />';
于 2013-07-10T14:26:20.647 回答
0

您可以使用PHPMailerSwiftMailer等免费 PHP 库来发送带有图像附件的电子邮件。

或者,如果您想创建自己的图像上传器,那么我建议您阅读有关文件上传的内容。您需要验证图像的真实性、检查扩展名并执行所有其他检查。阅读PHP 手册中有关文件上传的更多信息。

希望这可以帮助!

于 2013-07-10T14:27:12.887 回答