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 [email protected] to [email protected]
(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('[email protected]')
->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('[email protected]' => 'admin'))
->setTo(array('[email protected]' => '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: <[email protected]>
<< 550 5.1.1 <[email protected]> recipient rejected
!! Expected response code 250/251/252 but got code "550", with message "550 5.1.1 <[email protected]> recipient rejected "
>> RSET
<< 250 2.0.0 OK
++ Stopping Swift_SmtpTransport
>> QUIT