Failed Email Notifications - php

I am using phpmailer to send mail in Yii1. System which i have developed send thousand of emails daily. Normally it is working fine how ever sometime system fails to send email. After sometime that mail was delivered successfully (if system fails to send email first time then it will try again
). I am getting different types of email error some time. Not sure how to resolved those errors:
Mailer Error:
The following From address failed: test#test.com : MAIL not accepted
from server,x.x.x.x SMTP; Client was not authenticated to send
anonymous mail during MAIL FROM
[MWHPR11CA0017.namprd11.prod.outlook.com]SMTP server error: 5.7.57
SMTP; Client was not authenticated to send anonymous mail during MAIL
FROM [MWHPR11CA0017.namprd11.prod.outlook.com]
The following From address failed:
test#test.com : MAIL not accepted from server
SMTP Error:
Data not accepted.SMTP server error: 2.1.5 Recipient OK
The following From address failed:
test#test.com : MAIL not accepted from server,354,Start mail input;
end with < CRLF >.< CRLF >SMTP server error: Start mail input; end
with < CRLF >.< CRLF > SMTP server error: Start mail input; end with
< CRLF >.< CRLF >
SMTP Error:
The following recipients failed:xxx#xxx.com
So above is the different types of errors i have got sometimes. For #5 it seems that recipient was incorrect so that one is fine. But what about the others? How to solve them?

Depending on the MTA (mail transfer agent) installed on the server, ports used and SMPT settings, you may need to create the "from" user account on the server.
If you're using SSL/TLS, make sure the digital certificate(s) exist and has not expired. Also make sure your server's OS and MTA is up to date with the latest security standards -which if not compatible with latest industry standards may cause issues with the handshake/delivery mechanism.

you can always debug with command mail on your server. But as #argon already answered, the problem is probably with SMTP server.
I warmly suggest using external email marketing service if you are sending
thousand of emails daily.
Your server reputation will only get worse and will go straight to spam or rejected by SMTP (as in your case).

Related

Unable to send emails using Outlook SMTP accounts

When I send emails using outlook smtp i get following error
The server response was: 554 5.2.0
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied;
Failed to process message due to a permanent exception with message
Cannot submit message. 16.55847:69000000,
17.43559:0000000060010000000000000000000000000000, 20.521"
I have no problem with other smtp servers.
It relates to that issue
This applies to all email clients using smtp server to send email.
Sometime near the beginning of July, there was a change that
disallowed you using a return email address that is not in your list
of verified email aliases or connected accounts. In other words, you
can't change the "From" field in emails you send to an anonymous email
address.
So to send email from outlook 365 you need add alias email to list of verified emails.

PHP: how to test mailing to localhost on Linux and actually receiving it?

I'm building a daemon in php that checks for received emails which it then stores in the database leading them through a whole process. The thing is that I want to build some unit tests for this, for which I don't want to setup a whole mail server.
So for tests I want to somehow send emails to localhost, which should then be picked up by the daemon and processed further. So I tried the following:
$headers = 'From: me#mydomain.com \r\n Reply-To: me#mydomain.com \r\n X-Mailer: PHP/' . phpversion();
mail('www-data#localhost', 'THE SUBJECT', 'THE BODY IS HERE', $headers);
When I then run mail from the command line, I just get a message saying No mail for kramer65.
So my question; does anybody know how I can send emails to localhost in php, and how I can then read these emails from within php again? All tips are welcome!
[EDIT]
So I figured that it is sending an email to the www-data account, and not to my personal kramer65 account. I changed the to email address into kramer65#localhost, and when I now run mail I get
kramer65#php0:~$ mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/kramer65": 1 message 1 new
>N 1 kramer65e#php0 Fri Apr 25 10:48 16/495 THE SUBJECT
&
My following question is now; how do I read or somehow get this email from within php?
This depends on how you have configured the php internal mail settings. If you configured it to use a local mail forward agent (sendmail or similar) then you should be able to send messages to a local account (not a local email address) by just specifying the account name. At least this is what such agents offer. Unless php explicitly prevents such usage it might be worth a try.
You cannot send to a local email address, since that requires an email server, specifically an smtp server (exim or the like). Without it there is no component that could accept an incoming message.

Swiftmailer Error: Recipient Rejected

I am trying to get Swiftmailer to work but keep getting "recipient rejected" messages.What causes the "recipient rejected" response? Is this a response from the gmail server (gmail sensing this is SPAM)? Is there a way to overcome this? Otherwise, I will abandon Swiftmailer and try PHPMailer. I've had success with PEAR packages in the past but got tired of the configuration and was going to try Swiftmailer first...it shouldn't be this difficult right?
My Configuration:
- PHP 5.5.6
- Swiftmailer 5.0.3 (with Logger Plugin)
- Hosting by GoDaddy (yeah...I know)
Goal: Use Swiftmailer to send SMTP message from admin#mydomain.org to legit#gmail.com
(obviously the email addresses are placeholders for actual addresses)
Here is the PHP code: (same as example in Swiftmailer documentation)
<?php
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.mydomain.org', 25)
->setUsername('admin#mydomain.org')
->setPassword('mypassword')
;
$mailer = Swift_Mailer::newInstance($transport);
$logger = new Swift_Plugins_Loggers_EchoLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('admin#mydomain.org' => 'admin'))
->setTo(array('legit#gmail.com' => 'recipient'))
->setBody('Here is the message itself')
;
$result = $mailer->send($message);
echo $logger->dump();
?>
Here is the relevant logger info:
...
++ Swift_SmtpTransport started
...
>> RCPT TO: <legit#gmail.com>
<< 550 5.1.1 <legit#gmail.com> recipient rejected
!! Expected response code 250/251/252 but got code "550", with message "550 5.1.1 <legit#gmail.com> recipient rejected "
>> RSET
<< 250 2.0.0 OK
++ Stopping Swift_SmtpTransport
>> QUIT
Not a "real" answer, but too long for the comment box:
Is this a response from the gmail server
Yes.
recipient rejected means that, somehow, the recipient (that is, the address you're sending mail to, legit#gmail.com`) is "rejected".
This can have a number of causes
Email address doesn't exist (anymore) (quite probable)
User mailbox is full (quite probable)
The account is blocked by gmail (quite probable)
the user set a filter to explicitly reject emails from you (not sure if this can be done using gmail, but it's technical possible).
Your message is considered spam (unlikely, you would probably get a different message)
... many others...
It's somewhat unfortunate that gmail doesn't provide more info as to the cause. I can't find any documentation on gmail's error codes (550 is a generic "it failed" code), and usually these sort of messages are more verbose ...
What you could try:
Make very sure the email exists and is valid. Use a different gmail address (ie. one accessible by you) to be sure.
Check if you're blacklisted, for example using: http://mxtoolbox.com/blacklists.aspx
Try sending mail from smtp.mydomain.org, for example with the commandline mail utility (if it's a UNIX box), if this doesn't work, you know the problem is at the mail server, if it does work, you know the problem is at Swift mailer.

Swift Mailer does not return smtp mail failure

I am using Swiftmailer to send emails with SMTP
I need to get response from SMTP, but what I am trying is not working. Is it even possible?
I tried an invalid email: dima44324d#vdaszdsd1dw.com - on the code below, which does not return errors
if (!$mailer->send($message, $fails))
{
echo "Failures:";
print_r($fails);
return false;
}
return true;
P.S. I don't want to use PhpMailer because I have other issues with it.
Remember that Swiftmailer simply hands the email over to an SMTP server. It does not actually deliver it. It's not Swiftmailer's job to determine if the email address you're telling it to send to is valid or not. As long as the address conforms to RFC822 standards, it'll be accepted by Swiftmailer, and be accepted by whatever SMTP server you're using.
It's only when that SMTP server attempts to actually DELIVER the email to the invalid hostname that you'll get a failure. By that point, Swiftmailer's already disconnected and reported success - it has accomplished its mission. The failure has occured farther down the line, outside of Swiftmailer's view.

sending mail from my domain in php

I'm trying to send a mail from my own domain server like xyz#mydomain.com in php.
I can successfully send mail using gmail account with pear package. But, sending messages from my own domain fails.
any idea..... how I should send messages from my own domain. I'm getting errors like
authentication failure [SMTP: SMTP server does not support authentication (
code: 250, response: EMU.dnsracks.com Hello [72.18.135.214] TURN SIZE 2097152
ETRN PIPELINING DSN ENHANCEDSTATUSCODES 8bitmime BINARYMIME CHUNKING VRFY OK)]
My mail address is xyz#mydomain.com
Any help would be appreciated.
you don't need to use smtp, just use the phpmailer class.
http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html
very easy to use and you'll be sending emails in minutes!

Categories