Page 1 of 1
Help getting started (can't send even simple email) [solved]
Posted: Fri Jan 18, 2008 6:48 pm
by Chalks
Firstly, I'm glad Swift Mailer exists. Without it, I'm sure I would be even more confused than I currently am. That said, I can't figure out how to even send a basic email with Swift.
Here's what I'm trying to do:
Code: Select all
require_once "../swift/Swift.php";
require_once "../swift/Swift/Connection/SMTP.php";
require_once '../includes/header.inc.php';
// ... ... ...
$u = "username"; //not the actual value
$activationCode = "theactivationcode"; //not the actual value
$subject = 'Forum Activation';
$body = "Welcome to the forums, " . $u . ". To activate your account, please go to the following link: http://forums.chalksdesign.com/activation.php?u=" . $u . "&code=" . $activationCode . " Please do not reply to this email. Thank you!";
$swift = new Swift(new Swift_Connection_SMTP("mail.chalksdesign.com"));
$message = new Swift_Message($subject, $body);
if($swift->send($message, $e, "forums@chalksdesign.com"))
header('Location: /?e=new');
else
echo "something bad happened";
Am I missing something obvious? I've tried this with various email addresses, and none seem to work.
Thanks.
Edit: oh wow. This is my first post since the site redesign, and I'm _very_ impressed. Especially the nifty line numbers. <3
Re: Help getting started (can't send even simple email)
Posted: Fri Jan 18, 2008 7:07 pm
by Chris Corbyn
Where did $e appear from in your send() line? Apart from that it looks ok really.
Re: Help getting started (can't send even simple email)
Posted: Fri Jan 18, 2008 8:02 pm
by Chalks
$e is the email I want to send to. It changes based on what is put in the form.
Edit: I'm wondering if the problem might be on line 15 in the code above? All the other code snippits I've seen using Swift contain "smtp.whatever.com", whereas I'm using "mail.chalksdesign.com". I tried replacing that with "smtp.chalksdesign.com", but no dice... an error was thrown. So, how can I know for certain that my smtp server is what I say it is?
Re: Help getting started (can't send even simple email)
Posted: Fri Jan 18, 2008 8:25 pm
by Chris Corbyn
Ok, thanks, I'll have to see a log output. I'm guessing this mail server is for incoming mail only.
Code: Select all
require_once "../swift/Swift.php";
require_once "../swift/Swift/Connection/SMTP.php";
require_once '../includes/header.inc.php';
//Turn on logging
$log =& Swift_LogContainer::getLog();
$log->setLogLevel(4);
/*** Put your code here ***/
//Dump the log out
echo '<pre> . htmlentities($log->dump(1)) . '</pre>';
Re: Help getting started (can't send even simple email)
Posted: Fri Jan 18, 2008 8:31 pm
by Chalks
output:
Code: Select all
++ Log level changed to 4++ Trying to connect...++ Trying to connect to SMTP server at 'mail.chalksdesign.com:25<< 220-superbee.websitewelcome.com ESMTP Exim 4.68 #1 Fri, 18 Jan 2008 20:30:11 -0600220-We do not authorize the use of this system to transport unsolicited,220 and/or bulk e-mail.>> EHLO [70.87.57.162]<< 250-superbee.websitewelcome.com Hello superbee.websitewelcome.com [70.87.57.162]250-SIZE 52428800250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP++ SMTP extension 'SIZE' reported with attributes [52428800].++ SMTP extension 'PIPELINING' reported with attributes [].++ SMTP extension 'AUTH' reported with attributes [PLAIN, LOGIN].++ SMTP extension 'STARTTLS' reported with attributes [].++ SMTP extension 'HELP' reported with attributes [].>> MAIL FROM: <forums@chalksdesign.com><< 250 OK>> RCPT TO: <onionman@onionman.com><< 250 Accepted>> DATA<< 354 Enter message, ending with "." on a line by itself>> <MESSAGE DATA>>> .<< 250 OK id=1JG3TH-0002iv-Qv++ Message sent to 1/1 recipients
I think lines 5 and 6 might be a problem, there. >.>
Re: Help getting started (can't send even simple email)
Posted: Fri Jan 18, 2008 9:06 pm
by Chris Corbyn
Lines 5/6 are actually relatively standard

I suspect your email is just being blocked as spam at the recipient's end, or your mail server has the email spooled and hasn't run the queue yet. How long ago did yo send?
I've checked your IP in a blacklist database and you're clear there. Your SPF record fits with your domain too so no problems there.
Effectively from Swift's point of view and from your SMTP server's point of view everything has worked fine, which is odd.
Re: Help getting started (can't send even simple email)
Posted: Fri Jan 18, 2008 9:09 pm
by Chalks
Chris Corbyn wrote:Lines 5/6 are actually relatively standard

I suspect your email is just being blocked as spam at the recipient's end, or your mail server has the email spooled and hasn't run the queue yet. How long ago did yo send?
I've checked your IP in a blacklist database and you're clear there. Your SPF record fits with your domain too so no problems there.
Effectively from Swift's point of view and from your SMTP server's point of view everything has worked fine, which is odd.
I've been testing this with guerrillamail.com, which as far as I know doesn't block _anything_. However... let me test with my gmail and my yahoo accounts.......
Edit: huh. That's very strange. Gmail works just fine, I got it within 1 minute. Yahoo doesn't seem to receive it, though I admittedly only waited 5 minutes (and I checked the spam folder and whatnot). I am concerned about anonymous email accounts (read guerrillamail) not being able to receive emails. Is there anything I can do to make more email clients more receptive?
Also, I guess the problem wasn't with the code, but with who I was trying to send to.
Also also, Thanks a TON for your prompt responses, I really appreciate it.
Edit 2: never mind, my yahoo account DID get it. I just didn't see it because I have emails that are dated 1/18/2038... about 36,000 of them. >.>