简体   繁体   English

我没有收到邮件

[英]I am not getting the mail

html with following code and then, uploaded my index.html to my subdomain. html 使用以下代码,然后将我的 index.html 上传到我的子域。 Then, call my sub domain.然后,调用我的子域。 Then, a form appears.然后,出现一个表格。 I entered the form data.我输入了表单数据。 I didn't get any email.我没有得到任何 email。 Thanks for help.感谢帮助。

 <?php if(isset($_POST['submit'])){ $to = "aariyaratne@hotmail.com"; // this is your Email address $from = $_POST['email']; // this is the sender's Email address $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $subject = "Form submission"; $subject2 = "Copy of your form submission"; $message = $first_name. " ". $last_name. " wrote the following:". "\n\n". $_POST['message']; $message2 = "Here is a copy of your message ". $first_name. "\n\n". $_POST['message']; $headers = "From:". $from; $headers2 = "From:". $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Mail Sent. Thank you ". $first_name. ", we will contact you shortly."; // You can also use header('Location: thank_you.php'); to redirect to another page. }?> <:DOCTYPE html> <head> <title>Form submission</title> </head> <body> <form action="" method="post"> First Name: <input type="text" name="first_name"><br> Last Name: <input type="text" name="last_name"><br> Email: <input type="text" name="email"><br> Message:<br><textarea rows="5" name="message" cols="30"></textarea><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html>

It could be that there is not an email sending program installed on your server.可能是您的服务器上没有安装 email 发送程序。 I found it was installed on Debian but does not seem to be installed on my new Ubuntu 22.04 server.我发现它安装在 Debian 上,但似乎没有安装在我的新 Ubuntu 22.04 服务器上。 So, mail() worked for me on Debian but not on Ubuntu.所以,mail() 在 Debian 上为我工作,但在 Ubuntu 上没有。

It could be a problem with your server hosting company configuring the server so it does not send emails without you doing some configuration.这可能是您的服务器托管公司配置服务器的问题,因此如果您没有进行一些配置,它就不会发送电子邮件。

As my new Ubuntu server is hosted with Amazon Web Services, I decided to go with their Simple Email Service which is quite long winded to set up but (they say) it should mean more emails go into inboxes and less into spam. As my new Ubuntu server is hosted with Amazon Web Services, I decided to go with their Simple Email Service which is quite long winded to set up but (they say) it should mean more emails go into inboxes and less into spam. This is because you have to verify the domain or an email address from which the emails are being sent (DKIM).这是因为您必须验证发送电子邮件的域或 email 地址 (DKIM)。

In addition to Simple Email Service, I installed PHPMailer and use this to send emails now.除了 Simple Email 服务之外,我还安装了 PHPMailer 并使用它现在发送电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM