PHP5 and a contact form
At home, on my little laptop, I made a simple webpage and I'm trying a contact form.
When I click on submit, instead of submitting, I get a window asking me what I want to open send_mail.php with. It suggests Geany. I have put my email in send_mail.php Quote:
Quote:
|
Configure whatever Web server you have running to handle serving PHP correctly.
|
Ok, thanks. I have apache2 installed.
Which conf file needs what addition? I am trying to run the webpage from /home/pedro/mywebpage This is my /etc/apache/mods-available/php5.conf I commented out the last bit. I thought it would make php work there. Quote:
|
I read some more and changed /etc/php5/php.ini
I inserted this Quote:
|
Can you please check that you've carried out all the necessary install steps here:
https://www.digitalocean.com/communi...tack-on-ubuntu |
[side note: I got a message that it would be impossible to send email from my home computer to the public internet. If that's true I can stop wasting my time.]
Thanks for that. I got apache2 working. I got the default page. So I moved my personal webpage to /var/www/html and it works, I see it when I enter localhost in Firefox. I got php working. I get the php info page. My problem seems to lie in sendmail. sendmail was present in /usr/sbin but it was a dummy, almost empty file. So I installed sendmail, which seems quite complex, a lot of files which may or may not need tweaking. I ran sendmailconfig and that's probably where the devil lies: too many settings, which are right for me?? I am in China, so I use mail.qq.com The domain is qq.com, POP3 is pop.qq.com:995 smtp is smtp.qq.com ports 465 to 587 I want my webpage to send mail to my qq mail address when the user clicks submit. php has the function mail() My contact form page does not give me any error message, but I do not get any mail. The trick here is, I believe, to get sendmail working. If you know a good link for that, I would be very grateful. I don't know if php can work with postfix, which is more 'native' to Ubuntu. This link is good, but I can't get sendmail to work. Is it really that difficult?? http://stackoverflow.com/questions/1...mail-on-ubuntu Maybe, when I get around to publishing my web page, it will work on the server. I would still like to make it work on my laptop, just for the experience. I think I need a working smtp server to send the mails. This does not work at the moment and I don't know why. I changed the email to my email. Quote:
Quote:
This: Quote:
Quote:
|
Googling ubuntu sending mail apache produces results such as the following:
http://askubuntu.com/questions/47609...-php-send-mail Have a read through the various results, which suggest both sendmail and postfix solutions. My advice would be to keep things simple and test whichever method you choose through the command line before testing it through php. Sorry I can't give you better help than that as I don't send mail through my local server. Perhaps someone else will be able to offer you better help. Please let us know how you get on. |
Well, I got the tip to use ssmtp, they said sendmail or postfix are both overkills for my purpose, which is just sending an email to me.
I installed ssmtp which uninstalls sendmail, puts a symlink in /usr/sbin I am getting closer. This is the last bit of my /var/log/mail this morning: Quote:
UseSTARTTLS=yes UseTLS=yes AuthUser=my_foxmail_account_name@foxmail.com AuthPass=my_password qq.com doesn't like this kind of 'satellite' log in probably. Any more tips?? |
Ok, I've just got ssmtp working on my test rig (Mint 17.3 64-bit Xfce). Here is how I did it. Replace gedit with your editor of choice and items in italics with your particular details. I've set this up with gmail - I would advise you to do that in the first place and then try with another email provider after you get it working.
Info taken from: http://www.havetheknowhow.com/Config...all-ssmtp.html Code:
sudo apt-get update Code:
sudo gedit /etc/ssmtp/ssmtp.conf Code:
# Config file for sSMTP sendmail Code:
My Account->Sign-in & security->Allow less secure apps: ON Code:
ssmtp destination_email_address Code:
To: destination_email_address Note that ssmtp gets the job done but has some drawbacks and caveats - see https://www.linux.com/news/ssmtp-sim...ative-sendmail. |
Hi, Good Morning!
Thanks for your efforts on my behalf! Very grateful! I looked through all the settings on my email settings, but I do not find anything corresponding to Quote:
Quote:
Quote:
In China you have to get a license (ICP Internet Content Provider license) to open a web site. We have that now, but the ISP says they have not yet been officially informed by the authorities, so web site is not public yet. Once our webpage is open I'll try this again from the web site. If it doesn't work then, I'll ask the ISP to help. Unless of course you have any other ideas! Thanks again! |
You perhaps missed the bit where I said "Then I went onto Gmail and changed the following setting:".
Code:
My Account->Sign-in & security->Allow less secure apps: ON Are you able to have access to a Gmail account to test carry out the steps I laid out? It will no doubt work with other email providers, although not all, but I know it works with Gmail. You shouldn't need to be playing around with other settings. Try to keep it simple. |
Good Morning,
been away for a few days, sorry for the late reply. I did note your advice about the setting, but qqmail does not have an equivalent setting, as far as I can see. We live in China. google is not available except using a vpn. I can't just open gmail. I have a vpn, but not everybody does, so I'd rather not use gmail. The mails sent from here may or may not arrive, depending on the mood of the government! qq is big in China, everyone has it. foxmail.com is just an alias for qq.com Once the site is open, I'll try this from there. We still haven't got a functioning webpage, they company still has not received official approval, although we have. |
Hi again,
to take up this thread again: now we have our web page online, but the contact form still will not work. I wonder if you have any idea why not. If you go to www.rapidresults.wang and then contact>send us a message you can see the contact form. A right click and you can view the source code. If you then click on send_mail.php you will see this error: Quote:
$email_address = $_REQUEST['email_address'] ; $comments = $_REQUEST['comments'] ; These variables are defined in send_us_a_message.html here, (at least that's what I thought): Where must I define them?? Quote:
Quote:
|
You may have other things wrong, but at a minimum:
method="post" therefore you should be using $_POST[], not $_REQUEST[]. |
As an afterthought:
It still won't work. The web hosting people are useless, they just say we don't know anything about web pages, but I think I may know why it will not work: The server is a Windows server and Windows does not/may not use PHP, it uses asp.net, whatever that is. I saw a tutorial on the net about how to set up a contact form using asp. Haven't tried it yet, but I will look into it. Can Windows use PHP? |
PHP works fine on windows IIS servers. You have to configure mail sending in windows to properly send mail from your php script. Google for php send email on windows server and you'll get plenty of hits like this one http://stackoverflow.com/questions/1...windows-server
|
Or switch to a hosting provider that offers Linux based hosting rather than Windows.
|
All times are GMT -5. The time now is 12:08 PM. |