Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Fromethius

macrumors member
Original poster
Jun 26, 2008
45
0
Pennsylvania
I cannot find any scripts online that work with my web server.

The web server has a built in utility for sending mail but it forces you to use their ugly contact forum, and the perl file is a bloated mess that none of us can begin to edit.

We don't care about anti-spam or anything. We already have the contact forum set up. We just need a simple 10 to 20 line perl file that can send an email to our webmaster.

After looking for scripts all day and night and testing around 20 or so, this still is not working. I've tried everything. There must be a mail server set up because the built in one sends the mail, but we need something simpler.

All the websites are saying not to use sendmail because it's bloated, and are saying to use this script instead of this one, etc. but we're not sure which to use or even if it is set up.

Thanks for any help.
 

Me1000

macrumors 68000
Jul 15, 2006
1,794
4
If you have PHP set up on your server the mail function is pretty straight forward.

Code:
<?php
     mail('you@yourdomain.com','subject', $_POST['message']);
?>

That would send the email to your address provided you configured it. Then the field in your form would be called "message" (hence the $_POST variable array using 'message')
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
I wouldn't say Perl has gone the way of the dodo. Myself and a number of my co-workers still use it.

Anyways, have you tried the obvious thing and ask your web host what they allow? That would be the simple approach.
 

Fromethius

macrumors member
Original poster
Jun 26, 2008
45
0
Pennsylvania
Yes, we're using networksolutions as a host and (domain provider?).

They don't specify (or at least I couldn't find) whether or not they support php and upon creating a phpinfo() file to test it, it doesn't display it, which leads me to believe they do not support it.

I used the same phpinfo file for my web server on my macintosh and it showed right up.

Perhaps we have a lower service package? Maybe it was never configured? Maybe they just don't support it?

I don't know, but I really want to use php because it seems so much simpler than perl (which I could not get to work at all yet!, including your article) and I actually know php.
 

ChrisA

macrumors G5
Jan 5, 2006
12,581
1,697
Redondo Beach, California
On any UNIX-like system you can send mail with just one line. See the "mail" man page for details. But basically it goes like this

Code:
mail -s "example subject line" someone@myplace.com < filename.txt

Then from Perl, PHP, Ruby or compiled C code or whatever, you send the above line to be executed by the shell. In Perl you'd just say "system foobar" to send the comand foobar to the shell.

Read the mail man page.
 

Fromethius

macrumors member
Original poster
Jun 26, 2008
45
0
Pennsylvania
Figured it out.

The problem was due to our domain still being on a Windows box. I had to call customer support and have all the emails and the domains moved to a Unix box.

Now PHP is working properly as defined in the phpinfo file. However, when I use the mail function, the mail is still not sent to me.

I called customer service again and they didn't know. They said I might have to find my own sendmail executable and reference it, but shouldn't they have included it?

Either way, I'm one step closer but still no e-mail.
 

SrWebDeveloper

macrumors 68000
Dec 7, 2007
1,871
3
Alexandria, VA, USA
YES, they should!!!!

On that Unix server, there are traditionally one of two MTA's, either sendmail or exim. Sendmail is the most common, Exim is arguably a little more secure depending on who you ask (I agree).

Go into the Unix shell and simply type in "sendmail -bp" or "exim -bpa" and see if either one exists. Those commands actually dump the mail queue, demonstrating if they're working properly.

If you can't find the MTA that way, this means the path environment isn't setup properly (probably) to run daemons without specifying path so perform one more simple search of each to double check:

"locate sendmail | grep bin" or
"locate exim | grep bin"

That searches for each and includes in the output any binary paths meaning that's where the deamon lives. Traditionally for each it's in /usr/sbin but this is how you find out for sure.

Once you have the proper path to the proper MTA (i.e. "/usr/sbin/sendmail") then run your phpinfo() page again and see what's set for the "Configuration File (php.ini) Path" variable. That''s the config file for PHP showing you the full path (usually /etc/php.ini) to the php.ini file.

Edit the php.ini file and set the variable "sendmail_path" accordingly:

(example path, use your own)

If MTA is sendmail: /usr/sbin/sendmail -t -i
If MTA is exim: /usr/sbin/sendmail -t

Note: Exim has a sendmail alias and doesn't need the -i parameter

Also set smtp_port=25 (the most common SMTP port)

Save php.ini

Restart the web server, and that should remedy things.

If not, contact tech support and tell them the MTA isn't working or PHP can't access it and ask them to debug the above settings. If they tell you they don't have an MTA or you can't access it, drop them and find another host!!!!! heh

-jim
 

Fromethius

macrumors member
Original poster
Jun 26, 2008
45
0
Pennsylvania
Thanks, after creating a php.ini file in the cgi-bin directory with these lines:

sendmail_path = /usr/sbin/sendmail -t -i
smtp_port = 25

It now works.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.