php mail works but I can not send mail to the company's webmail

advertisements

I'm trying to set up a contact form module in joomla website. the contact module works great for every of my personal email addresses such as [email protected] or [email protected], ect. But when I test it with my client's company mail recipient the mail function fails do to its work.

In order to get some more informations about the failure i set mailsender property to my personal mail address as follows:

$mailSender->setSender('[email protected]');
$mailSender->addReplyTo('[email protected]');

and this is what i got:

The original message was received at Sun, 21 Oct 2012 15:05:00 +0200 from [email protected]

----- The following addresses had permanent fatal errors -----

[email protected]
(reason: 553 5.3.0 <[email protected]>... No such user here)
(expanded from: [email protected])

----- Transcript of session follows -----

... while talking to [127.0.0.1]:
>>> DATA
<<< 553 5.3.0 <[email protected]>... No such user here
550 5.1.1 [email protected] User unknown
<<< 503 5.0.0 Need RCPT (recipient)

and in the attached file this:

Reporting-MTA: dns; xxxxxx.yyyyyyy.com
Arrival-Date: Sun, 21 Oct 2012 15:05:00 +0200

Final-Recipient: RFC822; [email protected]
Action: failed
Status: 5.3.0
Remote-MTA: DNS; [127.0.0.1]
Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... No such user here
Last-Attempt-Date: Sun, 21 Oct 2012 15:05:01 +0200

It seems the company webmail doesn't accept mails from its own server. Im not a email expert nor a expert php programmer. any ideas?

Follows the part of my joomla module in which the mail function is instatiated and launched:

 $mailSender = &JFactory::getMailer();
$mailSender->addRecipient($recipient);

$mailSender->setSender('[email protected]');
$mailSender->addReplyTo('[email protected]');

$mailSender->setSubject('Richiesta informazioni da sito web');
$mailSender->setBody($myMessage);

if ($mailSender->Send() !== true) {
  $myReplacement = '<span style="color: ' . $error_text_color . ';">' . $errorText . '</span>';
  //header("Location: $url",303);
  print $myReplacement;
  return true;
}
else {
  $myReplacement = '<span style="color: '.$thanksTextColor.';">' . $pageText . '</span>';
  print $myReplacement;
  return true;
}


You are relaying mail through localhost (you are talking to 127.0.0.1), so your local sendmail install likely thinks that it is supposed to handle mail for your domain instead of just relaying. There is no user on the system called info so it returns an error 550 No such user here.

Check /etc/mail/local-host-names and see if the domain is listed there, if it is comment it out and restart sendmail with service sendmail restart.

Also verify that you are allowing relay for localhost in /etc/mail/access, my file looks like this on CentOS 5.8 and Sendmail 8.13.8

Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY

Another option is to use the real mail server as an SMTP relay instead of sendmail on localhost - I can't say what it is for the domain in question, but probably smtp.example.com or mail.example.com. One additional caveat is that this server may require authentication to relay mail from your web server - you would need to check with your administrator and update your PHP code accordingly.