PDA

View Full Version : sendmail, forms and php script


Anniedog
2008-08-26, 08:16 AM CDT
I have just managed to get my webserver running and have now successfully managed to publish a prototype website. However I am going mad trying to work out how to get a contact form to work with sendmail. I have succeeded in confusing myself to the extent that I have almost lost the plot.

Can anyone assist with a correct sendmail.php script to use to get the contact form to forward the contact form to an existing email account on an isp? GET, POST or REQUESTI at this stage just need an idea of a working script so that I can adapt it to my needs.

I have sendmail enabled but I am confused as to what I should use in the .mc file to make it work. Any advice and/or links that anyone has would be much appreciated. I have googled so much but I just cannot seem to find a howto or tutorial that I can get to grips.

Also which ports need to be opened in the firewall for this and I assume as I am behind a router that I need to port forward to the server?

marcrblevins
2008-08-27, 09:00 PM CDT
I use this e-mail thingy, uses Apache/Perl.

http://nms-cgi.sourceforge.net/

Its to protect my e-mail address from the sniffer/spammers

Anniedog
2008-08-28, 01:02 AM CDT
marcrblevins

Thank you very much that was exactly the reason I was trying to get sendmail to work. I will give that a try.

But having invested hours and hours now in the mail server I still would like to get it sorted out even if it is just a project. I have also tried postfix and docecot but no matter what I seem to do with all three. I can only seem to get email on the local working. I have just uninstalled postfix and dovecot and am starting yet again with just sendmail setup. I would appreciate views on dovecot or fetchmail or indeed any others. dovecot at one point seemed promising though the .conf file just did not want to edit at all easily infact it was a real hassle dovecot -n seeming to throw up errors on every edit.

1. I have my site registered at mysite.no-ip.org (my isp address is dynamic mysite is not the actual name as it is not ready for advertising yet)
2. I have port forwarded in my router to the LAN server 192.168.0.6 ports 25 ,80, 110 and even 965
3. These ports have also been opened on the server firewall
4. My eth has been set up manually the server name linserver 192.168.0.6 255.255.255.0 gateway(router 192.168.0.1) and the dns addresses of my ISP 214.xx.xxx.xxx 214.xx.xx.xx are all there.
5. This ip address and name has been reserved in the router so that it stays static

I think I am getting myself confused on what the actual mail server address should be I really have got by self twisted here.
Could someone tell me should I have in /etc/hosts
192.168.0.6 linserver.mysite.no-ip.org
will I need this to be added anywhere else and what the mail server address should actually be?

I have assumed that it would be:

linserver.mysite.no-ip.org

and that an actual email address would be :

user@linserver.mysite.no-ip.org.


I have just come across a tutorial on a debian box for sendmail and it is saying to comment out:
FEATURE(`no_default_msa')dnl
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
DAEMON_OPRTIONS(`Family=inet, Name=MSP-v4, Port=submission, Addr=127.0.0.1')dnl
and add at the bottom of the file
MAILER(`local')dnl
MAILER(`smtp')dnl
and for the above set up
Cw linserver.mysite.no-ip.org
Cw mysite.no-ip.org
This seems to make sense to me but advice would be appreciated anyone. Or indeed any other sendmail changes that would be needed for the above set up.

marcrblevins
2008-08-28, 10:29 AM CDT
I dont think that is the correct name, double check with no-ip.com what your web site address will be. Then name your rig's hostname as the same name.

I use this to show my public IP address and compare that with my dyndns.org account. I use ddclient which updates my dyndns account every 15 minutes if needed. ddclient is in the Fedora repo.
http://www.dslreports.com/whois

For dovecot:

# Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps pop3 pop3s

Since you only port forward 110, change last line to:

# Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
protocols = pop3

That is all you had to change in the original /etc/dovecot.conf, nothing else.

For sendmail.mc:
Change:

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

To:

DAEMON_OPTIONS(`Port=smtp, Name=MTA, M=A')dnl

Near end of my sendmail.mc, added:

FEATURE(`always_add_domain')dnl
MAILER(local)dnl

Then:

su -
make -C /etc/mail
service dovecot restart
service sendmail restart

Anniedog
2008-08-28, 12:48 PM CDT
Well I have followed the instructions above and still no joy. I have tried to get to emails but get connection refused and delivering emails I just get the standard unable to deliver message. There is something major wrong here.
I have set the host name to the domain name only and have removed the old machine name. This has given me hassles in the router as the IP 102.168.0.6 is shown as just MYSITE now and the no-ip.org cannot be shown. Though this only had a problem for networked printer on the LAN. Samba is stll working fine.
This is a real pain as the scripts from nmm will not run neither will any sendmail.php I try. I can access everything else fine, just cannot get my head around this at all now.:(

marcrblevins
2008-08-28, 02:47 PM CDT
Forget the NMS scripts for now, your attention is dovecot/sendmail. Once those are working, you can add the others later.

Did you check your log files? I think its /var/log/secure, /var/log/messages, & /var/log/maillog to be looked at.

You may also want to run www.grc.com, try their Shields Up! to may sure those ports are open and port forward properly.

Anniedog
2008-08-28, 03:03 PM CDT
I have no error messages logged at all. Using telnet localhost will deliver mail to /var/mail etc addressed to me@mysite.no-ip.org so that is all ok it is just not working at all. If I send myself an email adrdressed the same from thunderbird via my isp. Port scan show all ports open except port 25 which is not shown using network tools in gnome. Uing active network services this port is shown to be listening however on loopback 127.0.0.1. The firewalls clearly show that this port is open and the router log show an smtp entry. I will try the www.grc.com :)

Anniedog
2008-08-28, 03:21 PM CDT
Well that was interesting I have the perfect security according to www.grc.com not a single port was replying (all showing stealth)and I have no reverse dns whatever that is? So obviously I am invisible to the internet. Any ideas what to try next? I can connect to my site from various machines using the domain address I have with no-ip. I just do not know if I should have some entries in resolve.conf etc?

Edit
Am I missing a service?

Anniedog
2008-08-28, 03:42 PM CDT
ah ha just done an individual port check 110 is open but port 25 is shown as closed cant work out why when both firewall s show it is open.

Anniedog
2008-08-28, 05:33 PM CDT
Finally I now think that my isp is blocking port 25 and that would explain the problem.This would seem to be a common situation with non commercial isp deals. So I will have to rethink the situation all I really require is that a contact form on the website hides my actual email address .
What I require is:
A form that once completed will email me the results avoiding having the email address available out on the web.
It is clear that both nmm and sendmail scripts will not work using the sendmail configuration at present as port 25 is blocked and using the sendmail server to use a server email address is not possible.

I can change the port for outgoing smtp in sendmail. But I cannot understand how this would work for me in practice as this email would still have to be sent to myself and the incoming port would still be blocked.Well at least that is how I have read this.

The easiest way is for me to create a seperate email address with my isp for site mail and use this say webmaster@myisp.com I do have a few spare.

I need to some how alter sendmail to use my isp's server to send emails to myself once the form has been completed.
I know that is easy in the sendmail.mc but I am uncertain as to what the situation is with the password required by my isp for sending the email and how that would work with sendmail automatically, as it does say in thunderbird.

If anyone has any ideas how this would work or has any other solutions that would help me. I would be extremely grateful. As it does seems and feel I am back to square one again and it is more googling as if I have not done enough:).

marcrblevins
2008-08-28, 11:10 PM CDT
Did you call your ISP and ask them if port 25 is closed for good?

Anniedog
2008-08-29, 03:29 AM CDT
No I will have to contact them and see what the situation is, however as stated above this email situation has become now a project for me and I would still like to find a way around this port 25 issue as a learning excercise if nothing more.
Though it must be admitted it does make my brain feel as if it wants to explode.

I have decided to try a port change to sendmail. If this works it would mean that I would at least be able to send e-mails out. the only downside is whether my isp will reject the email as it would have come from a non recognised mail server. It may still get through just marked as spam. For all I know maybe my isp may offer me a relay but anyway that will not stop me playing as I have nothing to lose apart from my sanity:)

I have seen some pages that use java scripts to do the email hidding and sending routines, however this would require the client to have java enabled. I will have to have a look further into that anyway as it may provide an alternative temp fix.

Anniedog
2008-08-31, 01:29 AM CDT
Just to keep things up to date. My ISP has informed me that they will/cannot (not capable) of removing this block on port 25. In fact I had a very clear message that I was not permitted to use their smtp servers for anything but my registrered email addresses. I tried to point out that all I wanted was to be able to forward email from my website contact page without releasing my email address out on the web. I would be setting up my own smtp server to do the sending. They did not seem to grasp the fact that if I used my actual email address on the site they would get just as many emails. I suppose they would not believe me when I said that I would not use it for creating thousands of email addresses and flooding their servers with spam or be setting up a multinational with thousands of employees etc. Bottom line is you get what you pay for and in fairness I will just have to put up or shut up when it comes to my ISP.

However I am now working on a work around using port 587 and some masqurading. I have come across a very good site and the information on it looks very promising, I will probably need ssl (more learning) so until updates get working I will just hold off a little as I have read that the recent outrage was an Openssl attack. If this works out I will post back my solution. Still if anyone comes across this thread and has any ideas please all input is welcome.

quacked
2008-08-31, 02:06 AM CDT
I haven't tried the " email " server set-up yet, But as I understand it ,, Google , gmail, and an email server, are possible, I too ,, ( along with a lot of other ISP's ) have port 25 blocked, ( I could opt out of having it blocked however , ) Would appreciate the site that you have found, that seems to have some useful information , , I've been looking into setting up the email server with a gmail account , relay, Which from what I have gathered was possible , The changing of the default ports, to other ports , is also needed to complete the setup,,,

Haven't as yet tried it and ,,, Until I am more confident in being able to set it up in a more secure, and correct manner am not going to try , However,,, I would like to see ,,, some of the possibilities for setting an email server up Thanks !!!

Anniedog
2008-08-31, 02:14 AM CDT
http://www.linuxha.com/other/sendmail/gmail.html

I did not feel able to post this as I havent got it working but this is run on FC6 so is near enougth and neil says he has had it running though he is stil playing. hope it helps