Jump to content

Recommended Posts

Hi folks,

 

This might be the easiest question you've ever answered.. I would like to know how the mail() function works, as when I run the following script I am getting an error:

 

<?php

ini_set('SMTP', 'localhost');

ini_set('smtp_port', '25');

$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();

 

if (mail($to, $subject, $message, $headers)) { echo "success"; } else { echo "failed"; }

?>

 

The error that I am getting is:

[Tue Apr 03 00:12:26 2007] [error] [client 127.0.0.1] PHP Warning:  mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\\Work\\Mysite\\mailAction.php on line 11

 

so basially i would like to know how i can send an email using my localhost.. PLEASE HELP

 

 

Link to comment
https://forums.phpfreaks.com/topic/45376-i-need-help-with-mail-pleaaaaaaaaase/
Share on other sites

Thanks for the information. I was given smtphm.sympatico.ca as my smtp server by my isp. So i tried setting my smtp to that (SMTP = smtphm.sympatico.ca in PHP.ini), and ran my code again.. but no luck.. Is there anything else that I need to configure?

 

Thanks,

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.