Jump to content

Archived

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

pluginbaby

what is the problem?

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?

Share this post


Link to post
Share on other sites
Have you checked the junk inbox of your hotmail account its being sent to? I've found emails generated by my scripts often end up there.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
I used a yahoo email address, and now I got the email.

Is there any way I can solve this problem that hotmail accounts also get the email?

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
sorry to dissapoint you but I still haven't got anything in my hotmail inbox or trash can.

I think there must be a way of doing it, cause if you register on a forum, you get an email too if you are using a hotmail account.

Anyone has some more ideas?

Share this post


Link to post
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

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites
You know I have the same issue. And have yet to fix it.


I will do some testing and see what I can come up with.


Good Luck,
Tom

Share this post


Link to post
Share on other sites
http://forums.whirlpool.net.au/forum-replies-archive.cfm/484996.html

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
Use an email address that is known to the server. Like you@yoursite.com

Share this post


Link to post
Share on other sites
Make sure the domain portion of the "From:" address and the address in the fifth parameter is the same as the domain that is sending the email message.

Ken

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.