Jump to content

what is the problem?


pluginbaby

Recommended Posts

[code]<?php

$to      = 'willem_sterckx2@hotmail.com';
$subject = 'test';
$message = 'hello';

mail($to, $subject, $message);
echo "email send";
?>[/code]

I used this piece of code to test that an email would be send to my if I run it.
I run it and it gives me the message: "email send". When I look in my inbox there is nothing there.

I checked if the email address is correct, and it is.
I waited 24 hours for the email to arrive, and still nothing.
I have send the email more then 1 time, so it should be there...

What can the problem be then?
Link to comment
Share on other sites

Most email programs expect to see a "From:" header or they will toss the email down the bit bucket. Add at least the fourth parameter to the mail() function:

[code]<?php
$to      = 'willem_sterckx2@hotmail.com';
$subject = 'test';
$message = 'hello';
$headers = 'From: youremail@address.here';

if (mail($to, $subject, $message,$headers)) echo "email send";
?>[/code]
Note: A successful return from the mail() function just means that your message was queued to be sent, not that it was sent successfully.

Also, hotmail.com has been notorious for filtering out email messages and not telling about it. If you have another email address you can use to test with, try that one.

Ken
Link to comment
Share on other sites

Okay, I tried with the "From ..." thing.

Still got nothing in my inbox...

Anyway, I want to use this for a registration. You register and an activation is send to your email address. If this doesn't work on hotmail, there is no point of building that, since a lot of people I know only have hotmail. :o
Link to comment
Share on other sites

If you are using a shared host on a Linux (UNIX) box, you probably also need to use the fifth parameter to the mail() function. This parameter sets the "Return-path:" header. If the domain in that header doesn't match the domain of the address in the "From:" header hotmail.com will toss the email.

The fifth parameter looks like:
[code]<?php $p5  = '-f youraddress@yourdomain.com'; ?>[/code] and is used like [code]<?php mail($to,$subject,$msg,$headers,$p5); ?>[/code]

Ken
Link to comment
Share on other sites

okay, I have added the 5th parameter:

[code]<?php
$to      = 'willem_sterckx@hotmail.com';
$subject = 'test';
$message = 'hello';
$headers = 'From: superadmin@billshakesphere.de';
$p5  = '-f superadmin@billshakesphere.de';

if (mail($to,$subject,$msg,$headers,$p5)) echo "email send";
?>[/code]

But when I runned it, I got this error:

[quote]Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE. in /srv/www/htdocs/web34/html/test.php on line 8[/quote]

What can I do about that then?
Link to comment
Share on other sites

here is another example of a simple one. You may want to read up on the use of the headers in the mail.

[code=php:0]mail($to, $subject, $message, "From: You<you@yoursite.com>\nX-Mailer: PHP/" . phpversion());[/code]

Give this a try

Hope this helps,
Tom
Link to comment
Share on other sites

Not sure. I would contact my host if I were you. Do you know what mail server they are using? If not I would send them an email with your issue.

This script that I posted is a functional [code=php:0]mail();[/code] format. Is is very basic but should work.

Good luck,
Tom
Link to comment
Share on other sites

well, it does work. But not with a @hotmail adres.

When I send it to my ...@yahoo.com it works. But when I send it at my ...@hotmail.com it doesn't work. What I want is that it works also on the @hotmail.com email address, cause the site where I want to use it for has a lot @hotmail.com email addresses, and if they can't recieve the email, there is no use of me creating this ;)

I hope you understand my problem and there is a way of fixing it...
Link to comment
Share on other sites

Ok I tried this and it worked

[code=php:0]if ($ccaddress=="" || $ccaddress==" "){
$header="From: $knownsender";

}else{
$header .="From: $knownsender\r\n";
$header .=" Cc: $ccaddress";
}
// $header.="Bcc: $bcaddress";

if (@mail($mailtos, $subject, $message, $header)){
echo "Your Email has been sent.";
}else{
echo "There was an error sending your Email";
}[/code]

$knownsender is an email address that is known to the server. I never thought to use this but it works just fine.

Give it a try.

Link to comment
Share on other sites

Hmm, I must be doing something wrong then:

[code]<?php
$mailtos = "willem_sterckx2@hotmail.com";
$subject = "test";
$message = "this is a testingmessage";
$knownsender = "willem_sterckx2@hotmail.com";

if ($ccaddress=="" || $ccaddress==" "){
$header="From: $knownsender";
}else{
$header .="From: $knownsender\r\n";
$header .=" Cc: $ccaddress";
}
// $header.="Bcc: $bcaddress";

if (@mail($mailtos, $subject, $message, $header)){
echo "Your Email has been sent.";
}else{
echo "There was an error sending your Email";
}
?>[/code]

This is the exact code I executed, but I didn't got any emails at my hotmail account, I was wondering, is the "$knownsender" correct?
Link to comment
Share on other sites

I did it without the 5th parameter. It works without it to.

I set up an email address at my domain called: automailer@....
I also changed the subject of my email, maybe MSN sees "test" as a spam subject.

Anyway, now it finally arrived. I tested a couple of times and it keeps working.

Thank you all of you for helping me out on this one ;D
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.