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@address.co.uk";

// 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
Link to comment
Share on other sites

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