Swift Mailer Support Thread (Split from Source)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

I forgot to add the right ip to the smtp server (dumb me) but now when i added localhost i got:

Code: Select all

Array ( [0] => Array ( [command] => [time] => 0.10498700 1150411519 [response] => 220 linux.site ESMTP Postfix ) [1] => Array ( [command] => EHLO wmegn.mine.nu [time] => 0.56513900 1150411519 [response] => 250-linux.site 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250 8BITMIME ) [2] => Array ( [command] => MAIL FROM:  [time] => 0.60940200 1150411519 [response] => 250 Ok ) [3] => Array ( [command] => RCPT TO:  [time] => 0.67469300 1150411519 [response] => 250 Ok ) [4] => Array ( [command] => DATA [time] => 0.75026400 1150411519 [response] => 354 End data with .  ) [5] => Array ( [command] => To: "david.wibergh@gmail.com" From: "david.wibergh@gmail.com" Reply-To: Subject: Some Subject Date: Fri, 16 Jun 2006 00:45:19 +0200 X-Mailer: Swift by Chris Corbyn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hello Joe it's only me! . [time] => 0.75058000 1150411519 [response] => 250 Ok: queued as B6F834DD83 ) [6] => Array ( [command] => QUIT [time] => 0.76919400 1150411519 [response] => 221 Bye ) )
Script:

Code: Select all

<?php
require('/srv/www/htdocs/Swift/Swift.php');
require('/srv/www/htdocs/Swift/Swift/Swift_SMTP_Connection.php');
//This sets up our connection object
$connection = new Swift_SMTP_Connection('localhost');
//The mailer will now establish a connection with the server
$mailer = new Swift($connection);
//If anything goes wrong you can see what happened in the logs
if (!$mailer->hasFailed()) //Optional
{
//Sends a simple email
$mailer->send(
'"david.wibergh@gmail.com" <david.wibergh@gmail.com>',
'"david.wibergh@gmail.com" <david.wibergh@gmail.com>',
'Some Subject',
"Hello Joe it's only me!"
);
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
else echo "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1);
print_r($mailer->transactions);
?>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

:?: What's the question? It worked.

Don't just copy and paste those examples and use them in production code. They are merely there to illustrate how Swift works. It may be a good idea to look at the examples and break them down whilst consulting the documentation :)
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

I just needed to test if it worked but i didn't get an email?
I won't use that code in my script, just wanted to test if it worked.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

NiGHTFiRE wrote:I just needed to test if it worked but i didn't get an email?
I won't use that code in my script, just wanted to test if it worked.
The email is queued for delivery. You might not see it in your inbox for 30 mins or so depending upon the server.
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

I haven't got it yes :/
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Has it been blocked by a Spam filter? The details you posted show that the SMTP server happily accepted your message and sent it off.

Reasons that it may be blocked as Spam are Blacklisting of your host, using a dynamic IP address to relay mail and the other obvious things like selling <span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span> or offering millions of dollars.
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

well it shoudn't. I've now tryed with both hotmail and gmail and none has arrived :/
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You wanna send one to chris AT w3style DOT co DOT uk ?

I have a spam checker installed on the server. If your mail is blocked as SPAM I'll have a copy in a MySQL database I've set up as my spam bin. I'll send you the spam report either way (even if the score is zero). Just give it the subject "SWIFT TESTING" so I can spot it easily.

Have you checked the obvious and made sure that your server is actually running delivery attempts? You may need to flush the queue.
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

I did it now, added your email so you should have gotten an email soon.
But i also saw that when i added my public ip adress in

Code: Select all

$connection = new Swift_SMTP_Connection('81.231.254.x');
Then it doesn't work. Refuses to connect. But if i take

Code: Select all

$connection = new Swift_SMTP_Connection('localhost');
It works.
But i've forwarded port 25 to my computer.

Have you checked the obvious and made sure that your server is actually running delivery attempts? You may need to flush the queue.
How would i do that?
Thanks.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

NiGHTFiRE wrote:I did it now, added your email so you should have gotten an email soon.
But i also saw that when i added my public ip adress in

Code: Select all

$connection = new Swift_SMTP_Connection('81.231.254.x');
Then it doesn't work. Refuses to connect. But if i take

Code: Select all

$connection = new Swift_SMTP_Connection('localhost');
It works.
But i've forwarded port 25 to my computer.
Try telnetting to your PC from outside on port 25. It sounds like it's not routing into your computer correctly for whatever reason (firewall?).
Have you checked the obvious and made sure that your server is actually running delivery attempts? You may need to flush the queue.
How would i do that?
Thanks.
Check the mail spool for messages (usually along the lines of /var/spool/mail/).
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

Did you get an email?
But i've forwarded port 25 :/


Edit: seems like i didn't do it correctly. It's port 25 on what protocol, tcp right?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

NiGHTFiRE wrote:Did you get an email?
But i've forwarded port 25 :/


Edit: seems like i didn't do it correctly. It's port 25 on what protocol, tcp right?
TCP/25 yes. No I don't have an email, it's not in my spam bin neither. Does the SMTP server work correctly? Have you tested it with anything else? Try running `/usr/sbin/postfix -q' since it may not be doing it's mail runs.

EDIT | If you have a software firewall running on your PC make sure port 25 is open on that as well as on the router.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Is it possible to send multiple emails...with each email having a slightly different body content.

I want to put "Dear username" at the begining of my emails.

It needs to be a HTML email
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Is it possible to send multiple emails...with each email having a slightly different body content.

I want to put "Dear username" at the begining of my emails.

It needs to be a HTML email
Hmm... templating plugin... it would be nice :)
Locked