473,624 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

bonski
53 New Member
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 14038
Purple
404 Recognized Expert Contributor
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 New Member
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 Recognized Expert Contributor
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_emai l.">\r\n";
if (isset($Cc_emai l) and $Cc_email <> ""){
$header .= "Cc: ".$Cc_email."\r \n";
}
if (isset($Bcc_ema il) 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_e mail1."<= here";
echo "here =>".$header."< = here";
//so this is where the problem is...
//if(mail("\"".$r eceiver_name."\ " <".$receiver_em ail1.">", $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 New Member
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@atpth ailand.com>\r\n ";
$header .= "Cc: skimmerboi@gmai l.com\r\n";
$header .= "Bcc: \r\n";
$header .= "Reply-To: kristian@atptha iland.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.c o.th');

if(mail("me <k_bonbon_h5@ya hoo.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 Recognized Expert Contributor
Hi,

I suggest you try changing:

[PHP]mail("me <k_bonbon_h5@ya hoo.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 Recognized Expert Contributor
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 New Member
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@atpth ailand.com>\r\n ";
$header .= "Cc: skimmerboi@gmai l.com\r\n";
$header .= "Bcc: \r\n";
$header .= "Reply-To: kristian@atptha iland.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.c o.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@atpth ailand.com>\r\n ";
$header .= "Cc: skimmerboi@gmai l.com\r\n";
$header .= "Bcc: \r\n";
$header .= "Reply-To: kristian@atptha iland.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 Recognized Expert Contributor
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 New Member
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
91042
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 objects. I was able to run my application fine for roughly 1500 email messages. The next time I tried sending mail, it stopped working with the message: "
8
28240
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" action="enquiry.php">
3
5666
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 error.. 454 5.7.3 Client does not have permission to submit mail to this server 1)please tell all watever the possiblities of this error....
2
6730
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: Win2k Web Server Apache: v2.2.8
5
4682
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 New System.Net.Mail.MailMessage() correo.From = New System.Net.Mail.MailAddress("MyAco...@turbonett.com.ni")
1
5483
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: ini_set("SMTP","mail.name.com"); // thats how I setup my outlook ini_set("smtp_port","25"); ini_set("sendmail_from","address@hotmail.com"); ini_set("auth", true); if(mail($admin_email,$email_subject,$message,"From:$check_email,Reply-to:$check_email")) {...
7
16897
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 line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
1
4049
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 set up the server because if user put username the form works but if left blanck this error message keeps coming up function procForgotPass(){
0
2231
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 applcation, we will be accessing client's desktop through through VNC client. the IP comes in the error is the one which we used while connecting the server through VNC viewer. Few days back this IP has been changed and they gave us a new one. we...
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.