473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

function mail(): error "SMTP server response: 501 #5.1.1 bad address"

bonski
53
hello everybody.. i just want to know what this error means...

Error: mail() [function.mail]: SMTP server response: 501 #5.1.1 bad address


the smtp set up was correct.. valid emails... and port. so im just wondering why this error still occurs.

looking forward for your suggestions.. thanks!
Jun 15 '07 #1
9 13964
Purple
404 Expert 256MB
Hi bonski and welcome to TSDN,

If you take a look at the rfc defining SMTP codes here you will see the error you are getting described as:

Expand|Select|Wrap|Line Numbers
  1. 5.X.X   Permanent Failure
  2.  
  3.        A permanent failure is one which is not likely to be resolved by
  4.        resending the message in the current form.  Some change to the
  5.        message or the destination must be made for successful delivery.
and

Expand|Select|Wrap|Line Numbers
  1.  X.1.X   Addressing Status
  2.  
  3.           The address status reports on the originator or destination
  4.           address.  It may include address syntax or validity.  These
  5.           errors can generally be corrected by the sender and retried.
and

Expand|Select|Wrap|Line Numbers
  1.      X.1.1   Bad destination mailbox address
  2.  
  3.           The mailbox specified in the address does not exist.  For
  4.           Internet mail names, this means the address portion to the
  5.           left of the "@" sign is invalid.  This code is only useful
  6.           for permanent failures.
so it looks like the mailbox you are sending to is not correct...

Post the code doing the mail send, lets take a look at that..

Regards

Purple
Jun 15 '07 #2
bonski
53
thanks purple.. ok.. here are the codes..


the values are just for dummies.. ^__^

Expand|Select|Wrap|Line Numbers
  1. //generate_newletter.php
  2.  
  3. $firstname = 'firstname';
  4. $lastname = 'lastname';
  5. $sendlog_message = 'message here';
  6.  
  7. $receiver_name = $firstname." ".$lastname;
  8.  
  9. $receiver_email1='k_bonbon_h5@yahoo.com';
  10. $receiver_email2=''; 
  11.  
  12. $sender_name = 'me';
  13. $sender_email = 'me@ourdomain.com';
  14. $Cc_email=$receiver_email2;
  15. $Bcc_email="";
  16.  
  17. $subject = 'test';
  18.  
  19. //this line.. opens our mail template...
  20. $message_arr = file('crm_template/sample.htm');
  21.  
  22. $msg = '';
  23. foreach ($message_arr  as $line_num => $line) {     
  24.        while (preg_match("/(฿)([\w]+)/i", $line, $found_var)) { // loop when found "@" in that line ($line)      
  25.           // ........(ß).....find the character when begin with "ß"
  26.           // .......([w]+)/i......(......) set of  sub pattern
  27.           //  .........................[\w] mean find word (can be combine of charactor +number)
  28.           // ..........................+   mean [w] can be more than one character
  29.           // ...........................i    (after "/") mean to match with case-sensitive              
  30.           $temp_var=$$found_var[2];    
  31.           $line=ereg_replace($found_var[0],$temp_var,$line);    
  32.  
  33.      } // end while (preg_match (...
  34.      $msg.= $line;                
  35. }// end foreach
  36.  
  37. include('send_email.php');
  38.  
  39.  
  40. the other page where na mail function is location.. here it is..
  41.  
  42. //send_email.php
  43.  
  44. $to = $sender_email;
  45.  
  46. $header    = "From: \"".addslashes($sender_name)."\" <".$sender_email.">\r\n";
  47. if (isset($Cc_email)){
  48.     $header   .= "Cc: ".$Cc_email."\r\n";
  49. }
  50. if (isset($Bcc_email)){
  51.     $header   .= "Bcc: ".$Bcc_email."\r\n";
  52. }
  53.  
  54. $header   .= "Reply-To: ".$to."\r\n";
  55. $header   .= "Content-Type: text/html; charset=TIS-620 \n";
  56. $header   .= "MIME-Version: 1.0 \r\n";
  57.  
  58. //in this line.. this is our smtp server... i dont know whats wrong with this.. but it works on outlook... ^__^
  59. ini_set('SMTP','mail.asianet.co.th');
  60.  
  61. //so this is where the problem is...
  62. if(mail("\"".$receiver_name."\" <".$receiver_email1.">", $subject, $msg, $header)){
  63.     echo 'SENT!!!!';
  64. }else{
  65.     echo 'FAILED!!!!';
  66. }
  67.  
thanks.. just inform me if there's something not right with these codes...
Jun 15 '07 #3
Purple
404 Expert 256MB
Hi Bonski,

That was interesting.. I think there were a couple of issues in there.. one is still unresolved.. try this as a working half way house:

send_email.php

[PHP]<?php
//the other page where na mail function is location.. here it is..

//send_email.php

$to = $sender_email;

$header = "From: \"".addslashes($sender_name)."\" <".$sender_email.">\r\n";
if (isset($Cc_email) and $Cc_email <> ""){
$header .= "Cc: ".$Cc_email."\r\n";
}
if (isset($Bcc_email) and $Bcc_email <> ""){
$header .= "Bcc: ".$Bcc_email."\r\n";
}

$header .= "Reply-To: ".$to."\r\n";
$header .= "Content-Type: text/html; charset=TIS-620 \r\n";
$header .= "MIME-Version: 1.0 \r\n";

//in this line.. this is our smtp server... i dont know whats wrong with this.. but it works on outlook... ^__^
ini_set('SMTP','sbs-server');
echo "here =>".$receiver_email1."<= here";
echo "here =>".$header."<= here";
//so this is where the problem is...
//if(mail("\"".$receiver_name."\" <".$receiver_email1.">", $subject, $msg, $header)){
if (mail($receiver_email1.">", $subject, $msg, $header)) {
echo 'SENT!!!!';
}else{
echo 'FAILED!!!!';
}
?>[/PHP]

the headers were being malformed cause the isset check was passed but the variables were actually == ""

the name element prefix to the email address on the mail() function isn't working for me - I pass it back to you to have a play..

Let me know how you get on..

Regards Purple
Jun 15 '07 #4
bonski
53
ei purple..

ok.. i think the problem was not with the $header variable.. because it was just concatenating the values... ok.. here's why..

i tried to create another page... without too much variables..

//test_mail.php
[PHP]
$header = "From: kris <kristian@atpthailand.com>\r\n";
$header .= "Cc: skimmerboi@gmail.com\r\n";
$header .= "Bcc: \r\n";
$header .= "Reply-To: kristian@atpthailand.com\r\n";
$header .= "Content-Type: text/html; charset=TIS-620 \n";
$header .= "MIME-Version: 1.0 \r\n";

echo $header;//here i display the $header.. there nothing wrong..

ini_set('SMTP','mail.asianet.co.th');

if(mail("me <k_bonbon_h5@yahoo.com>", "test", "message here", $header)){
echo 'SENT!!!!';
}else{
echo 'FAILED!!!!';
}
[/PHP]

so i had this short code.. still the same result.. uhmmm.. about the code.. 5.x.x means permanent failure.. im just wondering if there's any alternative solution for that.. or.. what's the best solution with that?

thanks again purple..^___^
Jun 15 '07 #5
Purple
404 Expert 256MB
Hi,

I suggest you try changing:

[PHP]mail("me <k_bonbon_h5@yahoo.com>", "test", "message here", $header)[/PHP]

to

[PHP]mail("k_bonbon_h5@yahoo.com", "test", "message here", $header))[/PHP]

that will work

Purple
Jun 15 '07 #6
Purple
404 Expert 256MB
Hi,

I have done a little reading on this - even got a book out !!

It would appear some MTA's don't support extended address or are rstricted in what the will support - I suspect this is the issue we are experiencing with your to format.

Regards Purple
Jun 15 '07 #7
bonski
53
hahaha.. what a crazy afternoon... ok

so now.. what i did, i follow your suggestion and also i took out the $header variable from the mail() function... and IT WORKS... thanks man...

here it is

[PHP]
$header = "From: kris <kristian@atpthailand.com>\r\n";
$header .= "Cc: skimmerboi@gmail.com\r\n";
$header .= "Bcc: \r\n";
$header .= "Reply-To: kristian@atpthailand.com\r\n";
$header .= "Content-Type: text/html; charset=TIS-620 \n";
$header .= "MIME-Version: 1.0 \r\n";
echo $header;
ini_set('SMTP','mail.asianet.co.th');
if(mail("k_bonbon_h5@yahoo.com", "test", "message here")){
echo 'SENT!!!!';
}else{
echo 'FAILED!!!!';
}
[/PHP]


uhmmm.. its really confusing.. coz the last time i used this code.. it was working.. coz i was trying to send html contents... so if i took this code out..

$header = "From: kris <kristian@atpthailand.com>\r\n";
$header .= "Cc: skimmerboi@gmail.com\r\n";
$header .= "Bcc: \r\n";
$header .= "Reply-To: kristian@atpthailand.com\r\n";
$header .= "Content-Type: text/html; charset=TIS-620 \n";
$header .= "MIME-Version: 1.0 \r\n";

how am i suppose to generate html contents on email.. i mean is there something wrong with this headers?

purple.. thank you so much for your time.. i really appreciate it.. ^__^..
Jun 15 '07 #8
Purple
404 Expert 256MB
Hi Bonski,

I am pleased you have it working..

as an aside if you haven't already, take a look at this.

sending text or HTML as the message body should make no difference.

Regards Purple
Jun 15 '07 #9
bonski
53
ei purple
thank you so much man..

and thanks also for the link you gave me about errors.. i knew about mysql_error().. but the error_reporting() is kinda new to me.. and i'd been looking for something like that since morning.. so that i could track down whats wrong.. so thank you so much..

take care always..^__^..
Jun 15 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Janna Deegan | last post by:
Hello all, First off, if there is a better place to post for an answer to this question, please feel free to point me there. I have some very strange behavior happening with my System.web.mail...
8
by: punitshrivastava | last post by:
Hi to All. I am Punit .I am back with new question .Please help me. I want to create one enquiry form in php.for this I code it: form code: <form name="enquiry" method="post" ...
3
nitindel
by: nitindel | last post by:
Hi All, Greetings..!! I am using Persits Software to send mail in my Project through ASP,VBSCRIPT... But Mail is not going to the recepient...instead it is showing the following strange...
2
by: Ronald Raygun | last post by:
I am calling the mail() function in a PHP script and I get the ff error: Warning: mail() : SMTP server response: 501 5.5.4 Invalid Address in C:\test\test.php on line 394 Relevant Info: OS:...
5
by: Don Quijote de Nicaragua | last post by:
Hi, everyone I try to send a simple e-mail witch this Code, but always send me a error messages: "ERROR: Failure sending mail." Thansk You. Don Quijote de Nicaragua. Elder Soto. Dim correo As...
1
by: creative1 | last post by:
I am trying to setup contactus page. and testing it to work throug localhostI. I ahve setup everything php.ini and even tred to use following to make sure that everything is ok: ...
7
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on...
1
by: lisa007 | last post by:
Warning: mail() : SMTP server response: 503 valid RCPT command must precede DATA on whenever user click on to get new password but doesnt fill in the username field it shows that message i have...
0
by: gspgsp | last post by:
When sending mail we are getting this error: SMTP, Server Response: '550 5.7.1 <xxxxx@yahoo.com>... Relaying denied. IP name possibly forged Before it worked fine. For hosting and testing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.