550 Unroute Address - Need Exim solution for all emails to come - php

I am getting an error which says " The response from the remote server was: 550 Unrouteable address " .
My host of the email is valid and working good. But I need something like kjcnjkhb#abc.com.mydomain.com , when an email is sent to such an address it should come to my admin email.
I've enabled " catch all" so if I put any random email swejdnewkdn#mydomain.com , I get it my admin email.
But need an email when such kind of email is entered: dewdjkln#abcdne.com.mydomain.com ,
I believe there are some setting to be done in Exim maybe to solve this. I need all emails which has my host to come in my email.
Thank you in advance

If the error you're describing, "500 Unroutable address", is being generated by the client, then the problem is that there is no DNS MX record for abc.com.mydomain.com. The client doesn't know what server handles abc.com.mydomain.com. Your mail server isn't even being hit.
You may need to configure your DNS with a catchall MX record. Something like this:
*.mydomain.com. 3600 IN MX 10 smtp.mydomain.com.

Related

Can't send mails through PHP, even I set MX records

I am using PHP's mail() function, but I am unable to send mails to the majority of servers.
It send mails to the GMAIL without problems...Probably the rest of servers simply deny my mails...I set the MX records of the mail servers that I need...And I changed my PTR record to mail.example.com......however stil cant send mails..How can I solve this problem?
In addition, messages' sender is displayed as "www-data#localhost"
(I am using Digital Ocean, Ubuntu 12.04)
Errors that I am getting in log file:
My unqualified host name (localhost) unknown; sleeping for retry localhost sendmail[11620]: unable to qualify my own domain name (localhost) -- using short name(errors that I get in mail.err); and in log file it shows some errors regarding verification, Do I need to install smt regarding STARTTLS=client
when using the mail() function ypou neet to set the SENDER as well as teh from/to etc.
i.e.
mail($to, $subject, $body, $headers, "-f ".$webmaster);
The important thing is that "-f ".$webmaster that allows you to override the default of 'www-data#localhost' as the BOUNCE address (Envelope sender) for failed mail..
Most mailers will reject e-mail with an invalid bounce address.
Many hosted servers will not let you set the -f value tho...it sets the 'real sender' and of course its a classic way to send spam..
Try with the -f and if it fails change your hosting company.
Or get yourself a virtual private server.
I had the same problem and one thing you can do is: open a ticket with digital ocean support. By default, new accounts have a block to send e-mails (to avoid spammers). They resolved quickly and greatly improved.
Another thing is: check your mail reputation. You can find some websites that can help with this, like mail-tester.com - This site provides a report with potencial issues to fix the problem.

PHP mail() fails to send mail to same domain name as server [duplicate]

I have a simple php script on my domain that sends me an email:
...
$toMail = "me#gmail.com"; //this works - I get the email at my gmail
$toMail = "me#mydomain.com"; //this doesn't - I get nothing
mail($toMail, $subject, $message, $header);
What setting to I change to fix this?
For the people using Google Apps for email, but having your host in other provider this are more detailed instructions for the people that is not very familiar with cPanel.
I could fix the problem of sending email from my domain using a PHP form, when sending the email to an account inside my domain.
i.e. mydomain.example Contact form sending email to contact#mydomain.example.
The above was not working even if my domain has the correct MX records for the domain using Google Apps.
As Mike noted (and others) above the problem was solved: Adding the MX records into the cPanel.
Enter into the cPanel
Go the the cPanel Mail section
Search for MX Entry Maintenance, sometimes there is no text above the icon.
Select the related domain
Change Email Routing to Remote Mail Exchanger.
Add all the Google MX records as they are in your domain configuration using the appropriate priority values.
You can check the records here and priorities
https://support.google.com/a/answer/174125
Double check that Remote Mail Exchanger. is selected.
With this setting I was able to send email using mail PHP function to an email account inside the same domain as my website.
Google App instructions talking about MX records
https://support.google.com/a/answer/54717?hl=en
I've had this problem myself, when I was redesigning a site recently.
There was an issue with the way our system was set up, so that the system thought that because the email was coming from the same domain it was a spam email and as such blocked it.
Check with your system administrator that you are allowed to be sending the emails etc.
Either that, or you'll have to modify the headers to have look like it's being sent from an external address. Hope you get it sorted.
If you use postfix, do this :
connect to your server via ssh.
edit your main.cf file :
nano /etc/postfix/main.cf
comment the following line with # :
# mydestination = ...
add at the end of the main.cf document :
mydestination =
reload your postfix configuration by running :
/etc/init.d/postfix reload
The top answer at https://serverfault.com/questions/65365/disable-local-delivery-in-sendmail seems correct to me. The gist of it is that you want the following in your sendmail.mc:
define(`MAIL_HUB`, 'example.com.')dnl
define(`LOCAL_RELAY`, 'example.com.')dnl
Where example.com is the domain in question.
You need to set an additional parameter on your mail function. On your working example you would need to prepend your email address with '-f' e.g.
mail($toMail, $subject, $message, $header, "-fme#mydomain.example");
I had the same problem and was able to solve it in the following way. I do not store mail locally on the server but use MX records on the registrar to direct mail into Google Apps. It turned out the MX records needed to be updated in Cpanel as well, as the server was not taking the MX records from the registrar but instead discarding since there was no local MX record or mailbox. I updated the MX entries on Cpanel to match the registrar's MX entries, and the problem was fixed instantly
Do you have your email hosted on a different server than the website? If that is the case the PHP script may be trying to send it internally in which case it'll just disappear, while the other target emails will get put on to the internet and routed properly.
The solution I found was to disable the mail server on your web host, and then PHP will put the message on to the internet to be sent properly.
With PostFix, Debian7, smtp Mailjet
If domain is my-domain.example, in /etc/postfix/main.cf, change
mydestination = my-domain.example, localhost, localhost.localdomain, localhost
to
mydestination = localhost, localhost.localdomain, localhost
I agree with Michael Hellein, the root problem could be your sendmail considering your domain example.com email accounts as local accounts. If so, here are few guiding links:
https://serverfault.com/questions/65365/disable-local-delivery-in-sendmail
https://serverfault.com/questions/102647/sendmail-to-local-domain-ignoring-mx-records-part-2
http://lists.freebsd.org/pipermail/freebsd-questions/2004-September/057382.html
http://objectmix.com/sendmail/367920-sendmail-ignores-mailertable-some-semilocal-domains.html
But in my case, using FreeBSD 8.2, what really did the trick was:
# cd /etc/mail
# vim freebsd.mc
Add these two lines:
define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl
Right before:
MAILER(local)
MAILER(smtp)
Then:
# make
This is output:
cp freebsd.mc host.example.com.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/cf.m4 host.example.com.mc > host.example.com.cf
cp freebsd.submit.mc host.example.com.submit.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/cf.m4 host.example.com.submit.mc > host.example.com.submit.cf
Then:
# cp sendmail.cf sendmail.cf.bak
# cp host.example.com.cf sendmail.cf
# /etc/rc.d/sendmail restart
Hope this saves some headaches to someone.
make sure you can actually send mail to your domain email account and then check your code/email make sure everything is spelled right.. if none of this helped i dont know what went wrong..
I had the same issue, and since I was hosted on another server for e-mail, I just had to disable the local mail server.
I had this problem a few times, and the culprit was if the email was being hosted on another server (e.g. Google Apps). When mail sends to the local domain, it doesn't bother doing a lookup on the MX record and therefore it will not get routed properly. The solution to this problem is just to simply have the mail function disabled on your server by your host.
I had this problem too. Disabling the mail server meant no email at all was sent! So the fix I did was to remove all local domain names from the /etc/mail/local-host-names file
I had a similar issue wherein all mails were being perfectly sent to other domains like gmail, live, yahoo etc but all mails would disappear on local domains.
I had a VPS server with godaddy which was linux based running Qmail.
I solved the problem by removing the specific domain names in var/qmail/control/virtualdomains file .
SMTP mail server could be an option too.
I spend more than 8 hour on this error and solve it just change the header to any other email address and it will work
Make sure your txt record is setup correctly for your domain. This usually happens when you do not put this in the txt record: # (None) v=spf1 include:_spf.google.com ~all
What worked for me is selecting Local Mail Exchanger:
Go to cPanel
Select Email Routing
Select your domain
Select Local Mail Exchanger
Local Mail Exchanger will enable you to send an email to an account of the same domain in GoDaddy: e.g.: an email to info#yourdomain.example
As explained by others, some servers are configured to reject emails missing a valid email address on the sending server. Check that the $headers string includes a defined valid email address From:foo#example.com.

How to check if a received email is legit?

I'm developing a system which gets emails from PIPE, verify if the email address which from the email was sent is in the client database, and write it into the database.
The problem is that I don't want to have security issues, and if someone sends an email with PHP to the system, it will log it too. So, how can I check if the email was sent by the properly mail server? I was thinking in getting the IP of the mail server of the domain and verify in Email Headers if it was sent from these server. So, if I got an email from test#hotmail.com, it would ping mail.hotmail.com and check if the email came from these IP address.
Anyway, if someone got a custom domain like yourdomain.com, running in a shared cPanel server, other people in these server could send emails with PHP and get the IP verify passed. So, I was thinking in checking if the email was sent with PHP or from a mail server, but I don't know how to do this.
What is your suggestion?
I was thinking in checking if the email was sent with PHP or from a mail server
You will not be able to find out the difference between these two normally. And email sent with PHP can look exactly the same like an email from a mail server and it is likely the case that an email sent with PHP is also an email from a mail server.
You can try to write a detection on your own (your own filter) based on the monitoring you do and finding out about wrong mails (or those reported back from your users if you can not monitor the emails deeply because of law regulations).
I found http://verify-email.org/ for you. They have an API so you can check the email adress by that service.
EDIT
When you check an email adres on the website you see this result:
MX record about gmail.com exists.
Connection succeeded to alt3.gmail-smtp-in.l.google.com SMTP.
220 mx.google.com ESMTP tz3si2159695bkb.62 - gsmtp
> HELO verify-email.org
250 mx.google.com at your service
> MAIL FROM: <check#verify-email.org>
=250 2.1.0 OK tz3si2159695bkb.62 - gsmtp
> RCPT TO: <test#gmail.com>
=550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 tz3si2159695bkb.62 - gsmtp
You can build your own check by logging in to an smtp server and send the commands you see above:
> HELO verify-email.org
> MAIL FROM: <check#verify-email.org>
> RCPT TO: <test#gmail.com>
You can check for errors or success messages in the output you get. I think it's not difficult to build in php.
Eh, this is my first time answering anything so sorry if I misunderstood. Anyways, if you're doing a check for the email in PHP, I have something that might be able to help;
If($_POST['email']){
$Email = $_POST['email'];
$Allowed = array('gmail.com', 'yahoo.com', 'ymail.com', etc..);
If(filter_var($Email, FILTER_VALIDATE_EMAIL)){
$Domain = array_pop(explode('#', $Email));
If(!In_Array($Domain, $Allowed)){
Echo 'Your response here...';
}}}
or for checking the email's characters, you can call a function or check it yourself;
Function checkEmail($Email){
return preg_match("/^[\.A-z0-9_\-\+]+[#][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $Email);
}
So it'd be something like;
checkEmail('email#domain.com');
That checks the input, and if it doesn't have the email characters, you can choose what to do.
Hope this helped!
Yes, there are many Email Verification tools out there. I personally like www.verifyemailaddress.org
But there are plenty of those tools to find.

How to check if e-mail is full?

Is there any way how to check response for e-mail status in PHP script? For example - if I have php script which uses functions like $mail->Send() - is there any way how to check return statuses before sending this email? It just check or send "fake" email or something to know for example if e-mail is full or other errors like these:
Remote host said: 552 4.2.2 User has full mailbox.
Or something like this:
Remote host said: 550 5.1.1 Sorry, no mailbox here by that name.
Thank you.
I really doubt you could do that because it would mean that bad intentioned people could scan servers for email addresses.

can't send email to addresses at my own domain

I have a simple php script on my domain that sends me an email:
...
$toMail = "me#gmail.com"; //this works - I get the email at my gmail
$toMail = "me#mydomain.com"; //this doesn't - I get nothing
mail($toMail, $subject, $message, $header);
What setting to I change to fix this?
For the people using Google Apps for email, but having your host in other provider this are more detailed instructions for the people that is not very familiar with cPanel.
I could fix the problem of sending email from my domain using a PHP form, when sending the email to an account inside my domain.
i.e. mydomain.example Contact form sending email to contact#mydomain.example.
The above was not working even if my domain has the correct MX records for the domain using Google Apps.
As Mike noted (and others) above the problem was solved: Adding the MX records into the cPanel.
Enter into the cPanel
Go the the cPanel Mail section
Search for MX Entry Maintenance, sometimes there is no text above the icon.
Select the related domain
Change Email Routing to Remote Mail Exchanger.
Add all the Google MX records as they are in your domain configuration using the appropriate priority values.
You can check the records here and priorities
https://support.google.com/a/answer/174125
Double check that Remote Mail Exchanger. is selected.
With this setting I was able to send email using mail PHP function to an email account inside the same domain as my website.
Google App instructions talking about MX records
https://support.google.com/a/answer/54717?hl=en
I've had this problem myself, when I was redesigning a site recently.
There was an issue with the way our system was set up, so that the system thought that because the email was coming from the same domain it was a spam email and as such blocked it.
Check with your system administrator that you are allowed to be sending the emails etc.
Either that, or you'll have to modify the headers to have look like it's being sent from an external address. Hope you get it sorted.
If you use postfix, do this :
connect to your server via ssh.
edit your main.cf file :
nano /etc/postfix/main.cf
comment the following line with # :
# mydestination = ...
add at the end of the main.cf document :
mydestination =
reload your postfix configuration by running :
/etc/init.d/postfix reload
The top answer at https://serverfault.com/questions/65365/disable-local-delivery-in-sendmail seems correct to me. The gist of it is that you want the following in your sendmail.mc:
define(`MAIL_HUB`, 'example.com.')dnl
define(`LOCAL_RELAY`, 'example.com.')dnl
Where example.com is the domain in question.
You need to set an additional parameter on your mail function. On your working example you would need to prepend your email address with '-f' e.g.
mail($toMail, $subject, $message, $header, "-fme#mydomain.example");
I had the same problem and was able to solve it in the following way. I do not store mail locally on the server but use MX records on the registrar to direct mail into Google Apps. It turned out the MX records needed to be updated in Cpanel as well, as the server was not taking the MX records from the registrar but instead discarding since there was no local MX record or mailbox. I updated the MX entries on Cpanel to match the registrar's MX entries, and the problem was fixed instantly
Do you have your email hosted on a different server than the website? If that is the case the PHP script may be trying to send it internally in which case it'll just disappear, while the other target emails will get put on to the internet and routed properly.
The solution I found was to disable the mail server on your web host, and then PHP will put the message on to the internet to be sent properly.
With PostFix, Debian7, smtp Mailjet
If domain is my-domain.example, in /etc/postfix/main.cf, change
mydestination = my-domain.example, localhost, localhost.localdomain, localhost
to
mydestination = localhost, localhost.localdomain, localhost
I agree with Michael Hellein, the root problem could be your sendmail considering your domain example.com email accounts as local accounts. If so, here are few guiding links:
https://serverfault.com/questions/65365/disable-local-delivery-in-sendmail
https://serverfault.com/questions/102647/sendmail-to-local-domain-ignoring-mx-records-part-2
http://lists.freebsd.org/pipermail/freebsd-questions/2004-September/057382.html
http://objectmix.com/sendmail/367920-sendmail-ignores-mailertable-some-semilocal-domains.html
But in my case, using FreeBSD 8.2, what really did the trick was:
# cd /etc/mail
# vim freebsd.mc
Add these two lines:
define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl
Right before:
MAILER(local)
MAILER(smtp)
Then:
# make
This is output:
cp freebsd.mc host.example.com.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/cf.m4 host.example.com.mc > host.example.com.cf
cp freebsd.submit.mc host.example.com.submit.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/cf.m4 host.example.com.submit.mc > host.example.com.submit.cf
Then:
# cp sendmail.cf sendmail.cf.bak
# cp host.example.com.cf sendmail.cf
# /etc/rc.d/sendmail restart
Hope this saves some headaches to someone.
make sure you can actually send mail to your domain email account and then check your code/email make sure everything is spelled right.. if none of this helped i dont know what went wrong..
I had the same issue, and since I was hosted on another server for e-mail, I just had to disable the local mail server.
I had this problem a few times, and the culprit was if the email was being hosted on another server (e.g. Google Apps). When mail sends to the local domain, it doesn't bother doing a lookup on the MX record and therefore it will not get routed properly. The solution to this problem is just to simply have the mail function disabled on your server by your host.
I had this problem too. Disabling the mail server meant no email at all was sent! So the fix I did was to remove all local domain names from the /etc/mail/local-host-names file
I had a similar issue wherein all mails were being perfectly sent to other domains like gmail, live, yahoo etc but all mails would disappear on local domains.
I had a VPS server with godaddy which was linux based running Qmail.
I solved the problem by removing the specific domain names in var/qmail/control/virtualdomains file .
SMTP mail server could be an option too.
I spend more than 8 hour on this error and solve it just change the header to any other email address and it will work
Make sure your txt record is setup correctly for your domain. This usually happens when you do not put this in the txt record: # (None) v=spf1 include:_spf.google.com ~all
What worked for me is selecting Local Mail Exchanger:
Go to cPanel
Select Email Routing
Select your domain
Select Local Mail Exchanger
Local Mail Exchanger will enable you to send an email to an account of the same domain in GoDaddy: e.g.: an email to info#yourdomain.example
As explained by others, some servers are configured to reject emails missing a valid email address on the sending server. Check that the $headers string includes a defined valid email address From:foo#example.com.

Categories