[FIXED] Send emails on the same host works; Fails on gmail,

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
xeorex
Forum Newbie
Posts: 6
Joined: Sat May 17, 2008 2:28 pm

[FIXED] Send emails on the same host works; Fails on gmail,

Post by xeorex »

I spent the day trying to make this email form work and everything goes very well as I manage to make MIME text/plain and html work with mail() and done it again with swiftmailer.

The problem is that where I successfully managed to send email with mail() to any email address, swift mailer fails to send to any external email address or not hosted on this server.

I need swift mailer in order to use SMTP Authentication instead of mail()
-> and start to wonder if it worth it as I was doing this to not be put into spam folder or less and now I am not being sent at all.

It's a linux RedHat server running php4 (still) and I am using swift mailer for php4.
I had an issue with the reverse DNS not working but that has been sorted this afternoon so when I lookup the IP address, the domain name comes back properly on a reverse DNS lookup tool now.

The header of the email received on my email address hosted on this server is as following:
*************************************************************************************

Code: Select all

 
From - Sat May 17 19:22:40 2008
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <me@mydomainname.com>
Delivered-To: 2-me@sameserverdifferentdomain.com
X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on
    servernumber.serverdomain.com
X-Spam-Level: 
X-Spam-Status: No, score=-3.3 required=7.0 tests=ALL_TRUSTED,AWL,BAYES_00,
    HTML_MESSAGE autolearn=ham version=3.1.9
Received: (qmail 24982 invoked from network); 17 May 2008 19:19:49 +0100
Received: from mydomainname.com (HELO ?89.198.156.244?) (89.198.156.244)
  by mydomainname.com with SMTP; 17 May 2008 19:19:49 +0100
Return-Path: <me@mydomainname.com>
To: me@sameserverdifferentdomain.com
From: LMe - Newsletter <me@mydomainame.com>
Reply-To: Me - Newsletter
 <me@mydomainname.com>
Subject: My Name - test reverse dns record
Date: Sat, 17 May 2008 19:19:49 +0100
X-LibVersion: 3.3.2_4
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_=_swift-299141728482f21c51cd5e0.20878733_=_"
Content-Transfer-Encoding: 7bit
Message-ID: <20080517181949.11497.515456831.swift@www.mydomainname.com>
 
This is a message in multipart MIME format.  Your mail client should not
be displaying this. Consider upgrading your mail client to view this
message correctly.
--_=_swift-299141728482f21c51cd5e0.20878733_=_
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
etc....
*************************************************************************************

I haven't got TXT record setup and I called my hosting company about this, they told me I didn't need to set this up as I am hosting my php script on the same server sending the emails.

When I send the email with while loop I can see all my different email addresses from my database succeed if there are hosted on the same server but I get the dreaded "failed" error message for any external email addresses.

I could copy my script here if you would like, I just didn't do it so that this message doesn't looks too long.

Any help would greatly be appreciated at this stage as I have not much more idea other than step back to what it used to be.




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I got it sorted.
I thought it authenticate since it send emails on domain name hosted on this server. The fact is it didn't.
I could send to those one even if I wasn't connected to smtp.

I had to change my host name from
$conn =& new Swift_Connection_SMTP("mail.mydomain.com");
to
$conn =& new Swift_Connection_SMTP("localhost");
to have it sorted.

Hope this will help someone to don't waist the time I did :crazy:
xeorex
Forum Newbie
Posts: 6
Joined: Sat May 17, 2008 2:28 pm

Re: [FIXED] Send emails on the same host works; Fails on gmail,

Post by xeorex »

Here is a complete swiftmailer setup working for SMTP with Authentication:

<?php

//Load in the files we'll need
require_once "swiftmailer-php4/lib/Swift.php";
require_once "swiftmailer-php4/lib/Swift/Connection/SMTP.php";
require_once "swiftmailer-php4/lib/Swift/Authenticator/LOGIN.php";

//Start Swift
$smtp =& new Swift_Connection_SMTP("mail.myserver.com");
$smtp->setUsername("myusername@myserver.com");
$smtp->setPassword("mypassword");

$swift =& new Swift($smtp);

//Create the message
$message =& new Swift_Message("My subject", "My body");

//Now check if Swift actually sends it
if ($swift->send($message, "client@email.com", "me@myserver.com")) echo "Sent";
else echo "Failed";
?>
ramseymord
Forum Newbie
Posts: 1
Joined: Wed Aug 27, 2008 3:50 am

Re: [FIXED] Send emails on the same host works; Fails on gmail,

Post by ramseymord »

OMG... you save my life... Thank you very much :D :D
Post Reply