Jump to content

does php mail works with hotmail?


ted_chou12

Recommended Posts

Hello, this is my code:
[code]
<?php
$to = "veryprivate@hotmail.com";

$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>
[/code]
does this code works with hotmail??
Link to comment
Share on other sites

I think if you just send an email using the standard [i]to[/i], [i]subject[/i] and [i]body[/i] then Hotmail moves it to the Junk folder.  I've had a few problems with that, however, once I added some optional headers, including [i]from[/i] it seemed to get through OK.

Regards
Huggie
Link to comment
Share on other sites

Okay, I had added in option headers:
[code]
<?php
$to = "veryprivate@hotmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: myname<veryprivate@hotmail.com>rn";
$headers .= "Return-Path: <veryprivate@hotmail.com>";

if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>
[/code]
I forgot to say, it always appears message successfully send, however, I never see any messages in my inbox...
and it still doesnt work for any email accounts, can anyone check this please?
and may I request for your email script that worked out HuggieBear?
Link to comment
Share on other sites

I achieved it with the minimum of headers...

[code]<?php
// Email details
$to = "myemailaddress@hotmail.co.uk";
$from = "email@mydomain.co.uk";
$subject = "Header Testing";
$body = "Test to see if this goes into the junk folder in Hotmail or not";

// Headers
$headers  = "From: " . $from . "\n";
$headers .= "Content-type: text/plain";

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

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.