Setting up Swift on a Godaddy (bleagh) server

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
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Setting up Swift on a Godaddy (bleagh) server

Post by Chalks »

G'day!

I'm a really big fan of Swift Mailer, and have been using it on a personal site for a couple months with no problems at all. Today, however, I took a site I built on my server, and moved it to a godaddy.com server and everything went kablooie. I'm not trying to do anything more complicated than just send a "hey, your buddy wants you to look at this" email. I'm not really sure what is wrong, or how to fix it. Does anyone have any ideas or advice on how to get a godaddy server playing nice with swift?

here's the email function I use. I'm not sure if "smtpout.secureserver.net" is the correct smtp client, but I've browsed through as many of godaddy's relevant help files as I could find with no pointers besides "use this!".

Code: Select all

function email($to, $from, $subject, $body)
{
require_once "swift/Swift.php";
require_once "swift/Swift/Connection/SMTP.php";
$swift =& new Swift(new Swift_Connection_SMTP("smtpout.secureserver.net"));
$message =& new Swift_Message($subject, $body);
if ($swift->send($message, $to, $from)) return true;
else return false;
}

I guess what I'm really asking is, "how do I troubleshoot this?"
Oh, also: It's a linux server, and php 5 is enabled.

Edit: Ahha, found an error... I have no idea what it means though:
Swift Mailer wrote:Fatal error: Uncaught exception 'Swift_BadResponseException' with message 'Expected response code(s) [250] but got response []' in /home/.../swift/Swift.php:250 Stack trace: #0 /home/.../swift
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Setting up Swift on a Godaddy (bleagh) server

Post by Chris Corbyn »

I don't use godaddy but my understanding is that on their low end shared hosting you can't establish socket connections other than on port 80 so swift can't operate. They have some firewall policies.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Setting up Swift on a Godaddy (bleagh) server

Post by omniuni »

GoDaddy has some weird restrictions.

I suspect that Chris Corbyn is correct. I had some mail trouble myself, and am preparing to move my client to either WebHostingBuzz or to my own Reseller account I just set up.

Possibly if you really want to use SwiftMailer, you can host it on another server. I once something similar for a friend on an ASP server. We used an iFrame to embed a mail form on my server.

Also, if you're not using some of SwiftMailer's advanced features, you could always try PHP's simple mail() function.

-OmniUni

EDIT: Awesome! Swift was developed by someone here!
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Setting up Swift on a Godaddy (bleagh) server

Post by Chalks »

Great. The more I learn about godaddy, the more I despise it. Unfortunately, my client wants to use it so unless I can convince them otherwise, I guess I'll try to get the mail() function to work (any tips/resource links?). Fortunately the emails needed are very simple.

If anyone has used swift successfully on a godaddy account though, I would love to know about it.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Setting up Swift on a Godaddy (bleagh) server

Post by omniuni »

Here's what I use to send eMail:

Code: Select all

<?php
 
$email = $_POST['email'];
$phone = $_POST['phone'];
$body = $_POST['body'];
$message = "eMail: ".$email."<br>Contact: ".$phone."<br>MESSAGE:<br>".$body;
if(isset($_POST['body'])){
    $headers = <<<stop_heredoc_headers
Content-type: text/html; charset=iso-8859-1
From: someone@somewhere.com
Reply-To: $email
stop_heredoc_headers;
    $text = $message;
    $to = $settings['email'];
    $subject = "Website eMail: \"".substr($body,0,30)."...\"";
mail($to,$subject,$message,$headers);
echo "Thank You. Your Mail Has Been Sent:<br><br>".$message."<br><br><a href=\"?\">Home</a>";}else{
echo <<<END
 
            <form method="post" action="?page=contact" name="simpleSender">
What's your eMail Address?<br><input size="30" name="email" /><br><br>
What's your Phone Number?<br><input size="30" name="phone" /><br><br>
Message:<br>
<textarea cols="60" rows="6" name="body" style="width: 98%; height: 260px;"></textarea><br>
<div align="right">
<input value="Send e-mail" type="submit" />
</div>
            </form>
END;
}
 
?>
Make sure to adjust the "action=x" in the form so that it goes to the same page.

Good Luck!
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Setting up Swift on a Godaddy (bleagh) server

Post by Chalks »

Thanks! I don't really understand this part of your code though:
omniuni wrote:Here's what I use to send eMail:

Code: Select all

    $headers = <<<stop_heredoc_headers
Content-type: text/html; charset=iso-8859-1
From: someone@somewhere.com
Reply-To: $email
stop_heredoc_headers;
What's "<<<stop_heredoc_headers"?
Don't you need quotations around the header data?

Edit: Never mind, I got things working quite well, surprisingly enough:

Code: Select all

function email($to, $from, $subject, $body)
{
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: ' . $to . "\r\n";
$headers .= 'From: ' . $from . "\r\n\n\n";
 
if(mail($to,$subject,$body,$headers))
  return true;
return false;
}
Worked like a charm. The extra "\n\n" at the end of the header is for gmail addresses... if you only have one \n, gmail displays all the headers in the message body.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Setting up Swift on a Godaddy (bleagh) server

Post by omniuni »

awesome! and thanks for the tip on gmail!
User avatar
Ilija Studen
Forum Newbie
Posts: 7
Joined: Thu Sep 07, 2006 10:58 am
Location: Novi Sad, Serbia

Re: Setting up Swift on a Godaddy (bleagh) server

Post by Ilija Studen »

Chris Corbyn wrote:I don't use godaddy but my understanding is that on their low end shared hosting you can't establish socket connections other than on port 80 so swift can't operate. They have some firewall policies.
Customer also reported a really weird issue with GoDaddy - if he sends emails where To and From are the same email will not get through or will be sent just partially :crazy: This is not so uncommon in our notification system (administrator sets his own address as global From and sometimes system needs to notify him).
Post Reply