我已将python文件上传到我的网络托管服务,并尝试查看它是否发送了经过测试的电子邮件,但是我收到一条错误消息,说 “在此服务器上找不到请求的URL /cgi-bin/murshed-email.py” Web主机在Apache.2.4.38 UNIX服务器上运行 如果有人可以帮助解决此问题,那就太好了,或者就如何尝试提供建议。 我将在下面附加我的python代码以及HTML表单 注意:为方便起见,我只是在密码应使用的地方放了一堆星号
import smtplib, ssl, cgi
form = cgi.FieldStorage()
sender_email = "umarfarooq05122@gmail.com" #Email being sent from
receiver_email = "umarfarooq0512@gmail.com" #Email being sent to
message = """\
Subject:Test
Body:"""+ searchterm = form.getvalue('Name')\
+ searchterm = form.getvalue('email')\
+ searchterm = form.getvalue('country')
+ searchterm = form.getvalue('message') #Message that will be sent
port = 465
password = "*****"
context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login("umarfarooq05122@gmail.com", password)
server.sendmail(sender_email, receiver_email, message)
HTML代码
<div class="enquiries">
<form method="post" name="contactemailform" action="/cgi-bin/murshed-email.py">
<div class="enqtitle">ENQUIRIES</div>
<div class="formclass">
<label for="name" class="namelabel" id="namelabel">First Name</label>
<input type="text" id="name" name="name" placeholder="Name">
<label for="email" id="emaillabel">Last Name</label>
<input type="text" id="email" name="email"placeholder="Email">
<label for="country" id="countrylabel">Country</label>
<select name="country" id="country">
<option value="Country">Choose Country</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
</select>
<label for="message" id="messagelabel">Message</label>
<textarea name="message" id="message" cols="30" rows="10" placeholder="Message"></textarea>
<input type="submit" value="Submit" id="submitbutton">
</div>
</form>