So, I'm about 2 weeks into trying to learn PHP and I'm working on cloud9, which doesn't support the mail() function. After a lot of looking around on here I thought I'd try Swiftmailer and Gmail. For some reason, I can't seem to get this right even after literally copying formats. I have no idea what I'm doing wrong, but I can't even get echo statements to print after the first line. I've looked at numerous previous posts. I know this is probably a really dumb problem, but I could really use some help. Any alternatives that would work better for me in cloud9 would also be appreciated if this isn't a possibility. Thank you so much for your time.
<?php
require_once '/swiftmailer/lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername(USERNAME)
->setPassword(PASSWORD);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('This is a subject')
->setFrom(array('[email protected]' => 'My Name'))
->setTo(array('[email protected]' => 'Some Name'))
->setBody('Hello world!');
$request = $mailer->send($message);
echo "Hello!";
?>
If I put an echo before $request, it still doesn't echo. Also, I am getting all this in my terminal:
Started apache2 [Tue Mar 24 18:39:11.139091 2015] [mpm_prefork:notice] [pid 12191] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations [Tue Mar 24 18:39:11.139160 2015] [core:notice] [pid 12191] AH00094: Command line: 'apache2'
==> /home/ubuntu/lib/apache2/log/access.log <== 10.240.52.53 - - [24/Mar/2015:18:39:17 +0000] "GET / HTTP/1.1" 200 4997 "https://ide.c9.io/hrguyll/seproject" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.73.244 - - [24/Mar/2015:18:39:21 +0000] "GET /mail.php HTTP/1.1" 500 205 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.169.157 - - [24/Mar/2015:18:39:27 +0000] "GET / HTTP/1.1" 200 4997 "https://ide.c9.io/hrguyll/seproject" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.52.53 - - [24/Mar/2015:18:39:29 +0000] "GET /main_login.php HTTP/1.1" 200 2589 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.215.225 - - [24/Mar/2015:18:39:42 +0000] "GET /testmail.php HTTP/1.1" 200 2277 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.169.157 - - [24/Mar/2015:18:39:44 +0000] "POST /mail.php HTTP/1.1" 500 205 "https://seproject-hrguyll.c9.io/testmail.php" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.73.244 - - [24/Mar/2015:18:39:57 +0000] "GET / HTTP/1.1" 200 4997 "https://ide.c9.io/hrguyll/seproject" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.215.225 - - [24/Mar/2015:18:40:01 +0000] "GET /testmail.php HTTP/1.1" 200 2277 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.73.244 - - [24/Mar/2015:18:40:04 +0000] "POST /mail.php HTTP/1.1" 500 205 "https://seproject-hrguyll.c9.io/testmail.php" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.169.157 - - [24/Mar/2015:18:40:11 +0000] "GET / HTTP/1.1" 200 4997 "https://ide.c9.io/hrguyll/seproject" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.169.157 - - [24/Mar/2015:18:40:15 +0000] "GET /mail.php HTTP/1.1" 500 205 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.73.244 - - [24/Mar/2015:18:40:35 +0000] "GET / HTTP/1.1" 200 4997 "https://ide.c9.io/hrguyll/seproject" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.169.157 - - [24/Mar/2015:18:40:41 +0000] "GET /mail.php HTTP/1.1" 500 205 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.169.157 - - [24/Mar/2015:18:41:28 +0000] "GET / HTTP/1.1" 200 4997 "https://ide.c9.io/hrguyll/seproject" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" 10.240.215.225 - - [24/Mar/2015:18:41:30 +0000] "GET /mail.php HTTP/1.1" 500 205 "https://seproject-hrguyll.c9.io/?_c9_id=livepreview1&_c9_host=https://ide.c9.io" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
$request
, does it hit that? Is there any output/feedback in the terminal? – Brady Dowlingswift_required.php
is definitely in the folder you are referencing? – Brady Dowling