Go Back   HostGator Peer Support Forums > Public Forums > Suggestions

Notices

Reply
 
Thread Tools
  #1  
Old 04-09-2008, 01:30 PM
zulu6595 zulu6595 is offline
Hatchling Croc
 
Join Date: Apr 2008
Posts: 11
Default has anyone tried to use phpmailer in hostgator?

I've been pulling my hair out for a whole day. The same code that I have on another server won't work here. If there are some examples, that'd be really sweet.
Reply With Quote
  #2  
Old 04-09-2008, 01:47 PM
Sam Sam is offline
Emperor Croc
 
Join Date: Jan 2007
Location: /bin/false
Posts: 3,057
Default Re: has anyone tried to use phpmailer in hostgator?

What error are you getting?
Reply With Quote
  #3  
Old 04-09-2008, 05:26 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: has anyone tried to use phpmailer in hostgator?

And can you post your code? Does your other server use PHP5?
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #4  
Old 04-09-2008, 07:20 PM
episkey episkey is offline
Junior Croc
 
Join Date: Feb 2008
Posts: 133
Default Re: has anyone tried to use phpmailer in hostgator?

I have PHPmailer working. I would need to edit my script to remove private info before posting, and I don't have time to do that today. I display the form and handle it all in the same page. For mailing I specify smtp with authentication turned on. That works with an email account I created for my primary domain (with a shared non-reseller account) using cPanel.

Make sure you have the correct path for class.phpmailer.php. Also make sure you have $MailServer = mail.yourdomain.com and not smtp.yourdomain.com. When you move a script from one server to another, it's often the little things.

Good luck. When I get a chance to edit my script, I'll post it.
Reply With Quote
  #5  
Old 04-11-2008, 12:55 AM
zulu6595 zulu6595 is offline
Hatchling Croc
 
Join Date: Apr 2008
Posts: 11
Default Re: has anyone tried to use phpmailer in hostgator?

I was able to get my script working if I change to SMTP server to mail.<mydomain>.com. I was trying to get to an external SMTP server, which doesn't seem to work. Maybe its a firewall issue at hostgator.
Reply With Quote
  #6  
Old 04-11-2008, 04:14 AM
episkey episkey is offline
Junior Croc
 
Join Date: Feb 2008
Posts: 133
Default Re: has anyone tried to use phpmailer in hostgator?

Glad you found a way to get your script working. I did a test and I was able to use an external SMTP server. Specifically, I was able to use a gmail account by following the example script for gmail that is included in the PHPmailer documentation. The key lines seem to be:

$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;

Here's the entire script from PHPMailer_v2.0.0/docs/use_gmail.txt:

<?php

// example on using PHPMailer with GMAIL

include("class.phpmailer.php");
include("class.smtp.php");

$mail=new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port

$mail->Username = "yourname@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password

$mail->From = "replyto@yourdomain.com";
$mail->FromName = "Webmaster";
$mail->Subject = "This is the subject";
$mail->Body = "Hi,<br>This is the HTML BODY<br>"; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body

$mail->WordWrap = 50; // set word wrap

$mail->AddAddress("username@domain.com","First Last");
$mail->AddReplyTo("replyto@yourdomain.com","Webmaster" );
$mail->AddAttachment("/path/to/file.zip"); // attachment
$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

?>
Reply With Quote
  #7  
Old 04-12-2008, 11:57 PM
zulu6595 zulu6595 is offline
Hatchling Croc
 
Join Date: Apr 2008
Posts: 11
Default Re: has anyone tried to use phpmailer in hostgator?

Sweet! This will come in handy as I'm using google apps for email.
Reply With Quote
  #8  
Old 07-16-2008, 01:47 AM
Rowshan Rowshan is offline
Hatchling Croc
 
Join Date: Mar 2008
Posts: 7
Default Mail(): Return True but cannot send

Mail(): Return True but cannot send
Dear Friends,
I have a script in my website for sending feedback.
It returns TRUE for mail() but it can't send email to receiver at all.
Why?
I have joomla nd drupal in my host but they work good and send emails successfully.
-----------------------------------
My script is as following:

$to = "admin@domain.org";
$sender = $_POST['email'];
$headers = 'From:'.$sender."\r\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-type: text/HTML; charset=utf-8'."\r\n";
$body = "<html><body style='font-family: Tahoma;'>".htmlspecialchars(nl2br($_POST['msg']))."<br><font color='#0000FF'>".$_POST['email']."</font></body></html>";
$send=mail($to, "WadiOnline News (Feedback) > ".$subject, $body, $headers);
if($send){
echo 'Thanks for your feedback!';
} else {
echo 'An Error happened in sending.';
}

Waiting for your ehlp.
Reply With Quote
  #9  
Old 07-16-2008, 05:44 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: has anyone tried to use phpmailer in hostgator?

Rowshan-- please don't post more than once. I answered in the other thread.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #10  
Old 07-16-2008, 06:34 PM
gwyneth's Avatar
gwyneth gwyneth is offline
Supreme Croc
 
Join Date: Sep 2006
Location: up north
Posts: 6,843
Default Re: has anyone tried to use phpmailer in hostgator?

Quote:
Originally Posted by slapshotw View Post
Rowshan-- please don't post more than once.
Particularly by digging up an old thread that's about another app.
Reply With Quote
  #11  
Old 07-16-2008, 08:01 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: has anyone tried to use phpmailer in hostgator?

Quote:
Originally Posted by gwyneth View Post
Particularly by digging up an old thread that's about another app.
Yes, it occurs to me I should have answered it here and complained there!
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #12  
Old 07-16-2008, 08:09 PM
gwyneth's Avatar
gwyneth gwyneth is offline
Supreme Croc
 
Join Date: Sep 2006
Location: up north
Posts: 6,843
Default Re: has anyone tried to use phpmailer in hostgator?

Quote:
Originally Posted by slapshotw View Post
Yes, it occurs to me I should have answered it here and complained there!
Nah, better here--the original post was, after all, off-topic itself but I thought it would be piling on to point out that that made digging it up to double-post about another app even worse.
Reply With Quote
  #13  
Old 04-03-2011, 06:57 PM
abeer786 abeer786 is offline
Hatchling Croc
 
Join Date: Apr 2011
Posts: 2
Default Re: has anyone tried to use phpmailer in hostgator?

Quote:
Originally Posted by episkey View Post
Glad you found a way to get your script working. I did a test and I was able to use an external SMTP server. Specifically, I was able to use a gmail account by following the example script for gmail that is included in the PHPmailer documentation. The key lines seem to be:

$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;

Here's the entire script from PHPMailer_v2.0.0/docs/use_gmail.txt:

<?php

// example on using PHPMailer with GMAIL

include("class.phpmailer.php");
include("class.smtp.php");

$mail=new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port

$mail->Username = "yourname@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password

$mail->From = "replyto@yourdomain.com";
$mail->FromName = "Webmaster";
$mail->Subject = "This is the subject";
$mail->Body = "Hi,<br>This is the HTML BODY<br>"; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body

$mail->WordWrap = 50; // set word wrap

$mail->AddAddress("username@domain.com","First Last");
$mail->AddReplyTo("replyto@yourdomain.com","Webmaster" );
$mail->AddAttachment("/path/to/file.zip"); // attachment
$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

?>
ok, so I used you're code, have put all the address/gmail information in it...
but when I try to execute it, I'm getting the error
Mailer Error: SMTP Error: Could not connect to SMTP host.

Can anyone give any idea how do I debug the code. Also is there anyway to make sure port 465 is open for my account?
Reply With Quote
  #14  
Old 04-03-2011, 07:23 PM
GvilleRick's Avatar
GvilleRick GvilleRick is offline
Emperor Croc
 
Join Date: Jan 2007
Location: Greenville, SC
Posts: 3,130
Default Re: has anyone tried to use phpmailer in hostgator?

Probably would have been better to start a new thread rather than reopen a nearly 3 year old thread. The poster of the code you posted hasn't posted in a couple of years.

Anyway, it could well be that the port is closed outgoing on the server but the only way to know for sure is to open a ticket with support and ask them if it is open and/or if it can be opened outgoing.
Reply With Quote
  #15  
Old 04-03-2011, 07:44 PM
abeer786 abeer786 is offline
Hatchling Croc
 
Join Date: Apr 2011
Posts: 2
Default Re: has anyone tried to use phpmailer in hostgator?

Quote:
Originally Posted by GvilleRick View Post
Probably would have been better to start a new thread rather than reopen a nearly 3 year old thread. The poster of the code you posted hasn't posted in a couple of years.

Anyway, it could well be that the port is closed outgoing on the server but the only way to know for sure is to open a ticket with support and ask them if it is open and/or if it can be opened outgoing.
yes, thought of opening a new thread...but I was using the code in the above post only, so thought it would be better to post here..
ok will contact support and update here
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 03:17 AM.