views:

111

answers:

3

I'm working on a contact form for my church website.

The church has an email already registered (it's POP3) and the hosting company says their mail server is mymail.brinkster.com .

With all that information, how can you send the form using mail()? The server won't show PHP errors. The current code looks like this:

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: *ChurchsEmail*' . "\r\n";

if(mail("*MyEmailHere*", "Setting Up PHP Email", "This would be the body of the email.", $headers))
{
        echo "The email was successfully sent.";
} else {
        echo "The email was NOT sent.";
}

All I get back is "The email was NOT sent."

So does anyone have any experience setting up an email form like this? My thanks to anyone who can help me out and any efficient ways of doing this, let me know!

A: 

You probably need to configure it. The cli/apache user need to have access to sendmail.

OIS
I don't have access to the PHP.ini file. Is it common for someone to have access to it?
NessDan
@NessDan - Yes, it should be.
Abs
A: 

To use the PHP mail() function directly, your server has to be properly set up with a mail server.

If you want to send mail over SMTP through an external account/server I suggest you use a library found here: http://phpmailer.worxware.com/
You could also use their PHPMailer-FE which will even convert your contact form into an email for you.

MGW
I saw that and decided I'd rather just stick with the basic mail() function.For our website we have a very basic hosting plan, do you think they would restrict access to setting up a mail on the server?
NessDan
Actually if it's a decent hosting company, they should see that the mail function works as it should. However, if you will send email from a mail address not associated with the mail server, it is going to get flagged as spam very easily.On a shared hosting plan, you will not have the option of setting up your own mail server.You should probably ask your hosting company for support.
MGW
A: 

I was searching through their support database and found out how to get email working. It told me to include a server-file called "class.phpmailer.php"

Article for Brinkster users.

Thanks everyone for the help!

NessDan