[英]sending a confirmation message automatically to a given email id
我有一个表格,其中包含电子邮件ID字段。 提交表单后,确认消息应自动发送到给定的电子邮件ID,该怎么办?
我想在php中做到这一点。
<?php mail($email, 'thanks for your comment', 'many thanks, we will get back to you'); ?>
要发送消息,请使用以下代码,
<?php
//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
对于激活码,使用您的数据库,创建一个带有电子邮件和数字auto_increment的表格,当他在数据库中注册时,在数据库中将创建自动代码并将该代码发送到电子邮件,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.