Feeling dumb - trouble getting started with swift mailer
Posted: Wed Jun 25, 2008 2:54 pm
Trying to just do a basic mail so I can begin to add this to the things I know how to do --- but I obviously need help can someone help get me on the right track - THANKS
1. <?php
2. require_once "Swift.php";
3. require_once "Swift/Connection/SMTP.php";
4. require_once "Swift/Authenticator/LOGIN.php";
5. $log =& Swift_LogContainer::getLog();
6. $log->setLogLevel(4);
7.
8. $smtp =& new Swift_Connection_SMTP("smtp.gmail.com", 587);
9. $smtp->setUsername("nbt9p54");
10. $smtp->setpassword("mypassword");
11. $smtp->setPort(587);
12. $log =& Swift_LogContainer::getLog();
13. $conn =& new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);
14. $conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
15. $log =& Swift_LogContainer::getLog();
16.
17. $swift =& new Swift($conn);
18. $log =& Swift_LogContainer::getLog();
19.
20.
21. $message =& new Swift_Message("My subject", "My body");
22. echo $log->dump(true);
23. $sent = $swift->send($message, "nbt9p54@gmail.com", "nbt9p54@gmail.com");
24. echo "Sent to $sent recipients";
25. ?>
Here is the log and error message
++ Log level changed to 4 ++ Forcing ESMTP mode. HELO is EHLO. ++ Forcing ESMTP mode. HELO is EHLO. ++ Authentication mechanism 'LOGIN' attached. ++ Trying to connect... ++ Trying to connect to SMTP server at 'tls://smtp.gmail.com:465 << 220 mx.google.com ESMTP q18sm11067920pog.13 >> EHLO [127.0.0.1] << 250-mx.google.com at your service, [71.131.35.174] 250-SIZE 28311552 250-8BITMIME 250-AUTH LOGIN PLAIN 250 ENHANCEDSTATUSCODES ++ SMTP extension 'SIZE' reported with attributes [28311552]. ++ SMTP extension '8BITMIME' reported with attributes []. ++ SMTP extension 'AUTH' reported with attributes [LOGIN, PLAIN]. ++ SMTP extension 'ENHANCEDSTATUSCODES' reported with attributes [].
Fatal error: Uncaught exception 'Swift_BadResponseException' with message 'Expected response code(s) [250] but got response [530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 q18sm11067920pog.13]<h3>Log Information</h3><pre>++ Log level changed to 4 ++ Forcing ESMTP mode. HELO is EHLO. ++ Forcing ESMTP mode. HELO is EHLO. ++ Authentication mechanism 'LOGIN' attached. ++ Trying to connect... ++ Trying to connect to SMTP server at 'tls://smtp.gmail.com:465 << 220 mx.google.com ESMTP q18sm11067920pog.13 >> EHLO [127.0.0.1] << 250-mx.google.com at your service, [71.131.35.174] 250-SIZE 28311552 250-8BITMIME 250-AUTH LOGIN PLAIN 250 ENHANCEDSTATUSCODES ++ SMTP extension 'SIZE' reported with attributes [28311552]. ++ SMTP extension '8BITMIME' reported with attributes []. ++ SMTP extension 'AUTH' reported with attributes [LOGIN, PLAIN]. ++ SMTP extension 'ENHANCEDSTATUSCODES' reported with attributes []. >> MAIL FROM: <nbt9p54@gm in C:\wamp\bin\php\php5.2.5\PEAR\Swift.php on line 250
1. <?php
2. require_once "Swift.php";
3. require_once "Swift/Connection/SMTP.php";
4. require_once "Swift/Authenticator/LOGIN.php";
5. $log =& Swift_LogContainer::getLog();
6. $log->setLogLevel(4);
7.
8. $smtp =& new Swift_Connection_SMTP("smtp.gmail.com", 587);
9. $smtp->setUsername("nbt9p54");
10. $smtp->setpassword("mypassword");
11. $smtp->setPort(587);
12. $log =& Swift_LogContainer::getLog();
13. $conn =& new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);
14. $conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
15. $log =& Swift_LogContainer::getLog();
16.
17. $swift =& new Swift($conn);
18. $log =& Swift_LogContainer::getLog();
19.
20.
21. $message =& new Swift_Message("My subject", "My body");
22. echo $log->dump(true);
23. $sent = $swift->send($message, "nbt9p54@gmail.com", "nbt9p54@gmail.com");
24. echo "Sent to $sent recipients";
25. ?>
Here is the log and error message
++ Log level changed to 4 ++ Forcing ESMTP mode. HELO is EHLO. ++ Forcing ESMTP mode. HELO is EHLO. ++ Authentication mechanism 'LOGIN' attached. ++ Trying to connect... ++ Trying to connect to SMTP server at 'tls://smtp.gmail.com:465 << 220 mx.google.com ESMTP q18sm11067920pog.13 >> EHLO [127.0.0.1] << 250-mx.google.com at your service, [71.131.35.174] 250-SIZE 28311552 250-8BITMIME 250-AUTH LOGIN PLAIN 250 ENHANCEDSTATUSCODES ++ SMTP extension 'SIZE' reported with attributes [28311552]. ++ SMTP extension '8BITMIME' reported with attributes []. ++ SMTP extension 'AUTH' reported with attributes [LOGIN, PLAIN]. ++ SMTP extension 'ENHANCEDSTATUSCODES' reported with attributes [].
Fatal error: Uncaught exception 'Swift_BadResponseException' with message 'Expected response code(s) [250] but got response [530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 q18sm11067920pog.13]<h3>Log Information</h3><pre>++ Log level changed to 4 ++ Forcing ESMTP mode. HELO is EHLO. ++ Forcing ESMTP mode. HELO is EHLO. ++ Authentication mechanism 'LOGIN' attached. ++ Trying to connect... ++ Trying to connect to SMTP server at 'tls://smtp.gmail.com:465 << 220 mx.google.com ESMTP q18sm11067920pog.13 >> EHLO [127.0.0.1] << 250-mx.google.com at your service, [71.131.35.174] 250-SIZE 28311552 250-8BITMIME 250-AUTH LOGIN PLAIN 250 ENHANCEDSTATUSCODES ++ SMTP extension 'SIZE' reported with attributes [28311552]. ++ SMTP extension '8BITMIME' reported with attributes []. ++ SMTP extension 'AUTH' reported with attributes [LOGIN, PLAIN]. ++ SMTP extension 'ENHANCEDSTATUSCODES' reported with attributes []. >> MAIL FROM: <nbt9p54@gm in C:\wamp\bin\php\php5.2.5\PEAR\Swift.php on line 250