簡體   English   中英

我沒有收到郵件

[英]I am not getting the mail

html 使用以下代碼,然后將我的 index.html 上傳到我的子域。 然后,調用我的子域。 然后,出現一個表格。 我輸入了表單數據。 我沒有得到任何 email。 感謝幫助。

 <?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>

可能是您的服務器上沒有安裝 email 發送程序。 我發現它安裝在 Debian 上,但似乎沒有安裝在我的新 Ubuntu 22.04 服務器上。 所以,mail() 在 Debian 上為我工作,但在 Ubuntu 上沒有。

這可能是您的服務器托管公司配置服務器的問題,因此如果您沒有進行一些配置,它就不會發送電子郵件。

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. 這是因為您必須驗證發送電子郵件的域或 email 地址 (DKIM)。

除了 Simple Email 服務之外,我還安裝了 PHPMailer 並使用它現在發送電子郵件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM