Forum Moderators: coopster

Message Too Old, No Replies

Mail() function -- SMTP server response: 550

Problem using mail() function

         

Msd192

11:57 am on May 8, 2008 (gmt 0)

10+ Year Member



Hello. I need your help to solve my problem...

I get this warning:
Warning: mail() [function.mail]: SMTP server response: 550 <email@example.com> No such user here in D:\Domains\example.com\wwwroot\mail.php on line 3

when using this simple code:
<?php
error_reporting(E_ALL);
if(mail('email@example.com','subj','mess')) print "sent.";
else print "not sent";
?>

What does this warning mean? any solution?

Thanks for any help.

jatar_k

12:23 pm on May 8, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Msd192,

have you tried using a valid email address?

Msd192

6:35 am on May 10, 2008 (gmt 0)

10+ Year Member



yes of course, I just replaced email & domain name in this code.
I dont know what this warning means, so I cant think of any solution...

Pico_Train

6:38 am on May 10, 2008 (gmt 0)

10+ Year Member



are you doing this locally on your pc or live?

Msd192

6:41 am on May 10, 2008 (gmt 0)

10+ Year Member



Not locally, Im doing this Live...

penders

9:36 am on May 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are you setting a From header/email address? Or is the From header invalid?!

From the mail() manual page [uk.php.net]:

Note: When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

Msd192

2:37 pm on May 10, 2008 (gmt 0)

10+ Year Member



Well as the code indicates, Im not using any additional parameters. However the default value is set in php.ini (phpinfo()-->sendmail_from).
Even when I set the additional_headers parameter, the same warning is reported!

penders

5:10 pm on May 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Bit of a long shot but... have you tried a more verbose example with a longer subject and message text, perhaps spanning several lines (separated with '\n'). Just in case the mail server is rejecting 'nonsense' emails?! (Just a thought)

jatar_k

11:29 am on May 11, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the trick here being that it's a mail error

550 means, as it showed, no such user or just that the user mailbox was unavailable. I also found mention of that error being the not allowed to relay as well. Are you using an address that you have sent with before?

Msd192

12:29 pm on May 11, 2008 (gmt 0)

10+ Year Member



Bit of a long shot but... have you tried a more verbose example with a longer subject and message text, perhaps spanning several lines (separated with '\n'). Just in case the mail server is rejecting 'nonsense' emails?! (Just a thought)

actually yes, since it failed to send mail, I decides to simplify the script to find out whats wrong...

the trick here being that it's a mail error

550 means, as it showed, no such user or just that the user mailbox was unavailable. I also found mention of that error being the not allowed to relay as well. Are you using an address that you have sent with before?

yes again! This script works well on other domains with the same email address...

Thank to all anyway...

[edited by: Msd192 at 12:34 pm (utc) on May 11, 2008]

chorny

3:12 pm on May 11, 2008 (gmt 0)

10+ Year Member



Try SMTP sending code from PEAR. It may not be secure, but it is a better solution.

jatar_k

4:04 pm on May 11, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> yes again! This script works well on other domains with the same email address...

but isn't that the point, this mail server doesn't like the address, doesn't really seem to have much to do with the script

try using another address that is valid on the mail server you are sending through

Rohan Shenoy

2:47 pm on May 12, 2008 (gmt 0)

10+ Year Member



Are you sure your web host has enabled the mail() function for your website.

Msd192

8:32 pm on May 14, 2008 (gmt 0)

10+ Year Member



Sorry for replying with delay...

but isn't that the point, this mail server doesn't like the address, doesn't really seem to have much to do with the script
try using another address that is valid on the mail server you are sending through

Actually I still have problem understanding what you exactly mean (valid on the mail server you are sending through)... I need to send email to any valid address ! However Ive tried other addresses, none of them were helpful!

Are you sure your web host has enabled the mail() function for your website.

I sent them an email, asking for help. They replied "Everything is Okay here!". Whats more, the warning doesnt seem to have anything with enabling the mail() function. Also the values in php.ini are ok.

Msd192

8:47 pm on May 14, 2008 (gmt 0)

10+ Year Member



[email.about.com ]

If mail() does not work for you, you have options, too. The mail() function included with stock PHP does not support SMTP authentication, for example. If mail() does not work for you for this or another reason, try the PEAR Mail package, which is much more comprehensive and sending mail almost as easily from your PHP scripts.

As chorny suggested... (thanks)

I dont know anything about it(PEAR), I should give it a try.