Jump to content

[SOLVED] Using SMTP to send an eMail


mendoz

Recommended Posts

Change the email address and the server name, upload it to the server, and then try loading it in a browser.  This is as simple as it gets, so don't try changing anything else just yet, lets see if we can at least get it sending.

[code]<?php
// This MUST be set to your mailserver (replace 'localhost')
ini_set('SMTP', 'localhost');

// Who's the mail to
$to_email = "[email protected]";

// Test Subject
$subject = "Test Email";

// Test Body
$body = "This is our test message.\n";

// DO NOT ALTER
$headers = "Content-type: text/plain";

if (mail($to_email, $subject, $body, $headers)){
  echo "Success\n";
}
else {
  echo "Failed\n";
}
?>[/code]

Huggie
Your welcome.  The [url=http://uk.php.net/manual/en/function.mail.php]mail()[/url] function on Windows acts very differently to that on *nix flavour boxes.

I got the information that I needed from the [url=http://uk.php.net/manual/en/ref.mail.php]Mail reference page[/url] in the [url=http://uk.php.net/manual/en/index.php]PHP Manual[/url] though.

Don't forget to use the new 'Solved' button on this topic.

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.