Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 05-07-2009, 11:05 AM
verlen verlen is offline
Hatchling Croc
 
Join Date: May 2009
Posts: 3
Default Mail sending using mail(), or phpmailer

Hello everyone,

I just switched to Hostgator a few weeks ago and tried my old sites on the server.
I found just one thing that doesn't work for me: mail sending.
I already read another thread about using phpmailer, but it didn't help me.
I configured phpmailer like this:

Code:
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "mail.domain.com"; // SMTP server
$mail->SMTPDebug  = 2;
$mail->SMTPAuth   = true;               
$mail->Host       = "mail.domain.com";
$mail->Port       = 26;                    server
$mail->Username   = "postmaster@domain.com"; // SMTP account username
$mail->Password   = "mypass";        // SMTP account password
$mail->Host =
the value comes from mail accounts->configure mail client icon.
I even tried with SMTP port 25.

The message I got is:

PHPMailer - SMTP basic test with authenticationSMTP -> FROM SERVER:220-gator778.hostgator.com ESMTP Exim 4.69 #1 Thu, 07 May 2009 11:00:06 -0500 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
SMTP -> FROM SERVER: 250-gator778.hostgator.com Hello www.domain.com
SMTP -> FROM SERVER:250 OK
SMTP -> FROM SERVER:250 Accepted
SMTP -> FROM SERVER:354 Enter message, ending with "." on a line by itself
SMTP -> FROM SERVER:250 OK id=1M2610-0008Gp-5W
Message sent!


What is this????

by the way this
Code:
$body="asdkjhasdasd.";

$to = "my@email.com";
$subject = "whatever";
mail($to,$subject,$body);
does not work either.

please tell me what the problem is...
Or if you could tell me how to send a simple email using mail(), I could modify it and use it for phpmailer.

Thank you very much in advance.
Reply With Quote
  #2  
Old 05-07-2009, 01:04 PM
kirkman.enterprises kirkman.enterprises is offline
Hatchling Croc
 
Join Date: Apr 2009
Location: Texas
Posts: 5
Default Re: Mail sending using mail(), or phpmailer

The problem is the values it appears you are feeding phpMailer. "domain.com" should be your domain name. So in my case it would be:

PHP Code:
$mail->Host "mail.kirkman-enterprises.com"
Then username and password have to be for a valid email account that you've setup on that domain. Port 26 should work fine.

Hope that helps.
__________________
Kirkman-Enterprises.com
Reply With Quote
  #3  
Old 05-07-2009, 03:37 PM
verlen verlen is offline
Hatchling Croc
 
Join Date: May 2009
Posts: 3
Default Re: Mail sending using mail(), or phpmailer

Where you see "domain.com" there is actually the real domain name I use. Let's call it mysite.com, or yoursite.com, or whatever. domain.com was just for writing something instead of putting blank spaces. The email address exists as well. I even tried it with 2 addresses out of the 250 addresses I have for the site.
I just changed the names everywhere because it is not my site, I just moved the code from another server.
So, where "domain.com" is written there is in reality something else, but always the same name, say "mysite.com". (the site is not live yet and I don't want anyone to check it too soon )

By the way shouldn't the simple mail() function work right as well?

The strange thing is that I didn't see too many issues concerning email sending on Hostgator forums and here I am with a problem I could solve on 5 different servers until now...

Can someone please put here a code snippet so I can see a very simple email sending code? Or just the "configuration" of the phpmailer code. I would like to see how it works and contact support if something is wrong about my settings.
Reply With Quote
  #4  
Old 05-07-2009, 06:30 PM
Pitrow's Avatar
Pitrow Pitrow is offline
Swamp Croc
 
Join Date: Oct 2005
Location: Oregon
Posts: 379
Default Re: Mail sending using mail(), or phpmailer

try using the IP address of your server instead of the name, that's how I have it in the phpmailer instance I'm using...


Code:
$mail = new PHPMailer();

$mail->IsSMTP(); 
$mail->Host = "70.86.17.194";  
$mail->SMTPAuth = true;     
$mail->Username = "username";
$mail->Password = "password";
$mail->WordWrap = 50; 
$mail->IsHTML(true);    


$mail->From = "email@domain.com";
$mail->FromName = "Email Name";
$mail->AddAddress("recipient@domain.com"); 
$mail->Subject = "Subject";

etc.
Reply With Quote
  #5  
Old 05-07-2009, 08:56 PM
kirkman.enterprises kirkman.enterprises is offline
Hatchling Croc
 
Join Date: Apr 2009
Location: Texas
Posts: 5
Default Re: Mail sending using mail(), or phpmailer

You know, looking at your output, I'm not seeing an error message. I see the server responding OK and Accepted and phpMailer saying "Message Sent!" To turn off all the messages from being printed out you need to change this line:

PHP Code:
$mail->SMTPDebug  2
Change the 2 to a 1.

Now then, did you not get the email? Are you sending it to an email account at mysite.com/domain.com or to an e-mail account on another server? The other week I noticed an odd situation where sending e-mails to my GMail account from two different domains I run. I get the e-mails sent from one domain but not the other. On that other domain I don't get rejections in my mydomain.com email box and it doesn't turn up anywhere in my GMail account. (Weird.) After that, not sure what else to tell you.

As for mail() not working, I can't say for sure with HostGator, but I know that the mail function gets turned off in a lot of places for security reasons. It can be trivial to abuse forms that are not secured on the back end to send spam out using the mail() function. Requiring us to send mail using some form of authentication reduces the chance of abuse. Again, I'm not sure if this is HostGator's reason or not, just what I've seen working with other organizations that run web servers.
__________________
Kirkman-Enterprises.com
Reply With Quote
  #6  
Old 05-07-2009, 11:48 PM
eLIANT eLIANT is offline
King Croc
 
Join Date: Apr 2005
Posts: 1,075
Default Re: Mail sending using mail(), or phpmailer

Check your phplist documentation. I've never used phplist, but I'm guessing the only recognized values for "$mail->SMTPDebug" are true/false, or yes/no, or 1[any nonzero number]/0.

So the use of "2" - as far as PHP is concerned - is the same as "true", so you are running in debug mode; you're getting a "Succes" message but not sending an email.
__________________

eLIANT Technology Services
(site feedback welcome)
Reply With Quote
  #7  
Old 05-08-2009, 03:12 AM
verlen verlen is offline
Hatchling Croc
 
Join Date: May 2009
Posts: 3
Default Re: Mail sending using mail(), or phpmailer

I used the trick Pitrow wrote and now it's OK. I don't know what was the root of the problem, but it works now. Strange...
By the way I noticed that there are some email addresses I cannot send emails to, but this is the smallest problem now. The essential is that it is working.

Thank you everyone for your help. Have a better day than I had yesterday
Reply With Quote
  #8  
Old 05-22-2009, 07:20 PM
chathuragune chathuragune is offline
Hatchling Croc
 
Join Date: May 2009
Posts: 3
Default Re: Mail sending using mail(), or phpmailer

Did anyone get this script to work from using PHP Mail function:

mail('sendto@someone.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');

where -f forces the return path to be webmaster@example.com. I could not get the return path to work. However, it will send emails but will not set the return path as webmaster@example.com. Any help is really appreciated.

http://us2.php.net/manual/en/function.mail.php
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
mail() not sending mail in PHP script icon Shared Hosting Support 18 08-22-2008 08:59 PM
Sending E-mail through Mail Client Adorkable Shared Hosting Support 3 06-22-2008 04:04 AM
Mail sending error 421 chickens Network Status 0 06-30-2005 03:34 PM

All times are GMT -5. The time now is 01:32 PM.