php - Sending emails from ec2 using SES and SwiftMailer -
i have , running ec2 instance on california
node working except simple contact.php form.
i have read alot ec2 beingness hard send emails from. , is, nil seems working"
i have stumbled upon siftmailer , installed on ec2 instance running amazon's linux using yum install php-swift-swift.noarch
i have set ses credentials on oregon cluster (because don't have mailer on california one)
now code simple:
<?php require '/usr/share/pear/swift/swift_required.php'; $transport = new swift_smtptransport( 'email-smtp.us-west-2.amazonaws.com', 465, 'ssl', 'key' ,'secret' ); // $transport->setusername('') //create mailer using created transport $mailer = swift_mailer::newinstance($transport); //create message $message = swift_message::newinstance(); $message->setsubject("what up?"); $message->setfrom(array('mygmail@gmail.com')); $message->setto(array('mygmail@gmail.com')); $message->setbody(" <p> dude, i'm <b>totally</b> sending email via aws. </p> ", 'text/html'); $mailer->send( $message ); ?>
now error is
fatal error: uncaught exception 'swift_transportexception' message 'expected response code 250 got code "530", message "530 authentication required "' in /usr/share/pear/swift/swift/transport/abstractsmtptransport.php:386 stack trace: #0 /usr/share/pear/swift/swift/transport/abstractsmtptransport.php(281): swift_transport_abstractsmtptransport->_assertresponsecode('530 authenticat...', array) #1 /usr/share/pear/swift/swift/transport/esmtptransport.php(245): swift_transport_abstractsmtptransport->executecommand('mail from: executecommand('mail from: _domailfromcommand('mygmail@gmail...') #4 /usr/share/pear/swift/swift/transport/abstractsmtptransport.php(444): swift_transport_abstractsmtptransport->_domailtransaction(object(swift_message),
'mygmail@gmail...', array, in /usr/share/pear/swift/swift/transport/abstractsmtptransport.php on line 386
so 'mygmail' actual email set in post. , 'key' , 'secret' ones got when created credentials in iam ses instructions told me make.
also verified email on ses web interface well.
please allow me know if need create more clear.
not sure if fixed or not, might incorrectly used credentials, haven't specified info here.
i suggest seek replace: 'key'
email address 'mygmail@gmail.com'
'secret'
email address 'your_gmail_password'
such settings worked me on yii2 swiftmailer.
php email amazon-ec2 swiftmailer amazon-ses
No comments:
Post a Comment