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.
Related
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.
I receive the following error when trying send emails via a distribution list e.g email to SMS:
This is the mail system at host email-to-sms-0x.xxx.com.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
(expanded from
<7afc3e8f8de82#dist.test.com>): Command died with status
255: "/etc/mail/XXX.php". Command output: _
Final-Recipient: rfc822; dist-TEST-com#email-to-sms-02.test.com
Original-Recipient: rfc811;7afc3e8f8de82#dist.test.com
Action: failed
Status: 5.3.0
Diagnostic-Code: x-unix; _
The server uses postfix and I am unsure on how to proceed.
Would this be due to a php cronjob not executing or the permissions being incorrect?
Any help would be appreciated.
This is a Centos OS.
I have change some of the output to protect data.
Kind Regards
Ali G
You need to check the mail.log on email-to-sms-0x.xxx.com -- since Postfix doesn't disclose all information it obtained in the bounce.
It's probably a permission issue, yes :)
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.
I am piping all e-mails through a PHP script that checks the To address against a database of valid addresses. If it exists, the rest of the script handles it. However, if it does not exist, how can I bounce the e-mail, the same way the server would if I didn't have the script? Thanks!
The mails are recieved through smtp protocol, in your case also i assume that there is some service running on port 25 which would listen to request for mail from external domains.
There are different ways to bounce the message
->bounce at smtp level itself, as in when u get the recipient list, check f
or the id existance and if does-not exists give a 4xx response. The bouncemai
l would then be generated by the senders domain automatically.
-> if you have accepted the mail from the domain say gmail.com then u will
have to make a new connection to gmail with your bouncemessage, this is same
as sending a new mail from your server to gmail.com.
Turns out this was very easy to solve: Simply echo something in the PHP script (for example, "This account does not exist.") and the mailer daemon generates a bounce-back e-mail with this output included.
I am using Drupal with IIS7 and PHP to email the results of a form. the user fills out the form, the form is (supposed to be) emailed to me. The script runs without error, but there is no email sent. When I look in the queue folder for the virtual smtp server, there is the following:
Final-Recipient: rfc822;my#email.com *my email is here*
Action: failed
Status: 5.5.0
Diagnostic-Code: smtp;504 Need Fully Qualified Address
the php script is a standard mailto() with no frills, no headers or anything.
Any thoughts?
From the sounds of the error given "Need Fully Qualified Address", you are not passing a proper email address.
My suggestion is to verify you using a qualified address for both the recipient and the sender.
However, 504 error message usually means you have improperly command in the SMTP communication (which has to do with the internal protocols).
It would be helpful to see the entire code to be able to identify if this is protocol issue, or a parameter issue.