Jump to content

using the mail() function


nick1

Recommended Posts

Greetings,

To start, here are my system specs:
Ubuntu 6.06 LTS server
Apache2, MySQL, PHP5
(chose LAMP installation option during install of Ubuntu)
IPKungFu (firewall, all out-bound traffic is allowed)

My mail.php script:

[code]<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
  'Reply-To: webmaster@example.com' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?> [/code]

I copied the code from http://us2.php.net/function.mail simply to see if the mail function would work.  Of course I replaced 'nobody@example.com' with my real email address.
Now when I run mail.php, I'm not seeing an email in my inbox.  I waited for a few more minutes and refreshed my inbox, but still no email.  I'm new to the mail() function so I'm not sure what all is required to properly run it.  Does the mail() function require a mail server to be installed on my Ubuntu box?  I hope not, since all I want to use the mail() function for is to send myself alerts if certain parts of my code fail.

Thank you for your time,

*Nick*
Link to comment
Share on other sites

Ok. You will need to have a mail server installed to be able to use the mail function.


Well maybe not...

You could write a socket script that will use a free emails out going smtp server(.i.e. Gmail). That is somewhat difficult. I would say that would be for the moderate to high level php scripter.

Another alterative is the ether write a log file or use a database to store the errors. This is what I would do.

Good luck,
Tom
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.