8

I am trying to send mail to my local mail server. I am using hMailServer as mail server and I have configured it as mentioned here:

Setting up local Mail (SMTP, POP3, IMAP) Server on XAMPP

But when I try to send mail I am getting this error:

( ! ) Warning: mail() [function.mail]: SMTP server response: 550 The address is not valid. in C:\wamp\www\kariyersitem\register.php on line 161

Log files of the mail server indicates this error as below:

"DEBUG" 3108    "2012-01-08 18:04:24.447"   "Creating session 14"  
"SMTPD" 3108    14  "2012-01-08 18:04:24.448"   "127.0.0.1" "SENT: 220 localhost ESMTP"  
"SMTPD" 1728    14  "2012-01-08 18:04:24.454"   "127.0.0.1" "RECEIVED: HELO olcay-pc"  
"SMTPD" 1728    14  "2012-01-08 18:04:24.455"   "127.0.0.1" "SENT: 250 Hello."  
"SMTPD" 3108    14  "2012-01-08 18:04:24.457"   "127.0.0.1" "RECEIVED: MAIL FROM:<you@yourdomain>"  
"SMTPD" 3108    14  "2012-01-08 18:04:24.458"   "127.0.0.1" "SENT: 550 The address is not valid."  
"SMTPD" 2040    14  "2012-01-08 18:04:24.459"   "127.0.0.1" "RECEIVED: QUIT"  
"SMTPD" 2040    14  "2012-01-08 18:04:24.460"   "127.0.0.1" "SENT: 221 goodbye"  
"DEBUG" 3392    "2012-01-08 18:04:24.461"   "Closing TCP/IP socket"  
"DEBUG" 3392    "2012-01-08 18:04:24.462"   "Ending session 14"  

I have checked address and I am sure it is correct.
Can anyone tell me what is the problem?

Here my mail code:

$to      = $frm_kadi;  
$subject = $site_title.' Üyelik Aktivasyonu';  
$message = 'hello';  
$headers = 'From: '.$contact."\r\n".'Reply-To: '.$contact."\r\n".'X-Mailer: PHP/'.phpversion();  
$mresult = mail($to, $subject, $message, $headers);  

I have checked $contact and It is written as olcayertas@gmail.com in my config.php file. Before sending mail I have use echo function to debug my code and it is correct.

Currently my $contact variable is set to:

$contact = "olcayertas@gmail.com";

UPDATE 1

Setting sendmail_from to olcayertas@gmail.com in php.ini as @Jared Farrish suggested solved the first problem. But now I have a new problem:

"DEBUG" 3108    "2012-01-08 22:15:28.497"   "Creating session 24"  
"SMTPD" 3108    24  "2012-01-08 22:15:28.498"   "127.0.0.1" "SENT: 220 localhost ESMTP"  
"SMTPD" 3108    24  "2012-01-08 22:15:28.499"   "127.0.0.1" "RECEIVED: HELO olcay-pc"  
"SMTPD" 3108    24  "2012-01-08 22:15:28.500"   "127.0.0.1" "SENT: 250 Hello."  
"SMTPD" 4380    24  "2012-01-08 22:15:28.511"   "127.0.0.1" "RECEIVED: MAIL FROM:<olcayertas@gmail.com>"  
"DEBUG" 4380    "2012-01-08 22:15:28.542"   "Total spam score: 0"  
"SMTPD" 4380    24  "2012-01-08 22:15:28.547"   "127.0.0.1" "SENT: 250 OK"  
"SMTPD" 3108    24  "2012-01-08 22:15:28.548"   "127.0.0.1" "RECEIVED: RCPT TO:<olcayertas>"  
"SMTPD" 3108    24  "2012-01-08 22:15:28.548"   "127.0.0.1" "SENT: 550 A valid address is required."  
"SMTPD" 2040    24  "2012-01-08 22:15:28.552"   "127.0.0.1" "RECEIVED: QUIT"  
"DEBUG" 2040    "2012-01-08 22:15:28.552"   "Deleting message file"  
"SMTPD" 2040    24  "2012-01-08 22:15:28.552"   "127.0.0.1" "SENT: 221 goodbye"  
"DEBUG" 4380    "2012-01-08 22:15:28.555"   "Closing TCP/IP socket"  
"DEBUG" 4380    "2012-01-08 22:15:28.556"   "Ending session 24"  

It seems like it does not get destination address completely. I am trying to send mail to myself but it gets only username olcayertas and missing domain @gmail.com.

UPDATE 2

I have solved the second problem. It was my mistake.

UPDATE 3

Now I am getting this error:

"SENT: 530 SMTP authentication is required."

But I have already filled SMTP authentication settings under Settings->Ptotocols->SMTP->Delivery of e-mail->SMTP Relayer. Server requires authentication and Use SSL otions checked.

UPDATE 4

Disabling Require SMPTP authentication options of hMailServer in Settings->Advanced->IP Ranges->My Compter solved SMTP authentication problem.

Olcay Ertaş
  • 5,987
  • 8
  • 76
  • 112
  • Please tell us what your parameters for `mail()` are. – Jonathon Jan 08 '12 at 16:32
  • 3
    +1 for actually looking into the error log for a PHP related question. – hakre Jan 08 '12 at 16:33
  • What are the actual SMTP settings (within reason) that you're using? – Jared Farrish Jan 08 '12 at 16:45
  • What is `$contact`? This is the one giving you the problem, not `$to` (at least according to the [hMailServer docs](http://www.hmailserver.com/documentation/latest/?page=reference_error_messages_smtp)). – Jared Farrish Jan 08 '12 at 16:52
  • Also, you might want to do `"From: $contact\r\nReply-To: $contact\r\nX-Mailer: PHP/".phpversion();` as well. There's no reason to keep changing back and forth between quotes. (And I also saw somewhere that Gmail may ignore `Reply-To` header; if they're the same email, it's redundant. Remove what you don't need when you are debugging to eliminate silly mistakes.) – Jared Farrish Jan 08 '12 at 16:54
  • Have you tried `olcayertas@gmail.com` instead? Is your SMTP setup through another account other than that one? Also, the `$header` suggestion had more to do with how you were using quotes; I didn't expect it to "solve" the problem. – Jared Farrish Jan 08 '12 at 17:42
  • Whatever your problem is, I don't see it (and the hMailServer source code download is not available, so I can't look at that). The only other shot in the dark is that the email address itself does (or does not) contain some special characters as your name has, but you're not seeing them in the source file. I'd try another setup with a clean, "new" email address. Get something (from scratch) to work and compare. Also, you might ask on the hMailServer forums. – Jared Farrish Jan 08 '12 at 17:51
  • Nevermind, their website seems to be out of date. The source can be found here: https://github.com/hMailServer/hMailServer – Jared Farrish Jan 08 '12 at 17:59
  • 2
    This might help: http://www.hmailserver.com/forum/viewtopic.php?f=6&t=4685 – Jared Farrish Jan 08 '12 at 18:22

5 Answers5

11

To solve SENT: 550550 The address is not valid. problem, you have to set sendmail_from to a valid mail address in php.ini file.

To solve SENT: 530 SMTP authentication is required problem, open hMailServer Administrator. Go to Settings->Advanced->IP Ranges->My Compter. Disable all options under "Require SMTP authentication" section.

DreamTeK
  • 32,537
  • 27
  • 112
  • 171
Olcay Ertaş
  • 5,987
  • 8
  • 76
  • 112
  • 530 SMTP authentication: It works but had to change Internet settings instead of Computer settings to be able to send emails from localhost to same domain of webserver. Had to uncheck "local to local e-mail adresses" in Require SMTP authentication". Default sender in my php.ini is admin@webserv.com. It enables me to send emails to, for example: notify@webserv.com. – Codebeat Nov 05 '14 at 05:38
  • Amazing I send email wihtin my wamp localhost with hmailserver – Charlesliam Dec 15 '14 at 13:31
3

It seems that you are sending the "sender"-email (From-Header) like this: you@yourdomain. yourdomain is an invalid domain. Change this to a valid email-address.

Himanshu
  • 31,810
  • 31
  • 111
  • 133
TimWolla
  • 31,849
  • 8
  • 63
  • 96
1

You're using you@yourdomain as the From address and the server rejects it.
Use a real address instead.

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Daniel Vérité
  • 58,074
  • 15
  • 129
  • 156
  • I have checked it. It is written as olcayertas@gmail.com in my config.php file. Before sending mail I have use echo function to debug my code and it is correct. – Olcay Ertaş Jan 08 '12 at 16:35
  • OK, but there are two From addresses when sending a message: there is the From of the headers which is not used by SMTP, and the From of the envelope which is used by SMTP in the MAIL FROM command. This is the latter one that is giving you trouble. With sendmail, the envelope-From can be passed with the -f option. This kind of option can be passed to php mail() function in the _additional_parameters_ argument. – Daniel Vérité Jan 08 '12 at 18:17
0

KEEP IN MIND, every time, after You change php.ini,

you should restart wamp (! ! !)

to read the updated php.ini

p.s. you may need to use ini_set("sendmail_from", "your_user@gmail.com"); in your php script, before mail();

T.Todua
  • 53,146
  • 19
  • 236
  • 237
0

I'm guessing $contact is <olcayertas@gmail.com> and that's what's causing the problem. Try changing it to olcayertas@gmail.com.

Jonathon
  • 778
  • 8
  • 21