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