• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

php mailer question about smtp

I'm sending out a newsletter. I have tested this same script without specifying SMTP, so it sends from my web host. That works fine, except that Hotmail (only) seems to filter it into junk mail, so I decided to use SMTP server of my ISP. Now I know my ISP has blocked port 25, so in outlook express, I must use my ISPs SMTP server to send out emails. This works in Outlook Express, so I used the exact same settings to PHP mailer as in the SMTP settings section below, but when I run my script, I just get a blank and nothing happens - no error messages. Of course, the email was never sent out.

If I'm able to send using outlook express, shouldn't it mean that php mailer should also work using the same smtp server? Any advice on what I should do?

My script is as below

//SMTP settings
$mail->IsSMTP();
$mail->Host = "smtp.domain.com";
$mail->SMTPAuth = true;     // turn on SMTP authentication -- generally needed for most SMTP servers
$mail->Username = "myusername";  // SMTP username
$mail->Password = "mypass"; // SMTP password
      
$mail->From = "me@abc.com";
$mail->FromName = "Me";
$mail->Subject = "Newsletter";
$mail->IsHtml(true);
$mail->AddReplyTo("info@drum-jam.com", "Drum Jam");
$mail->Body = $emailText;
$mail->AltBody = "This is the body in plain text for non-HTML mail clients.";
$mail->AddAddress("me@abc.com", "Me");
$mail->AddBCC("you@abc.com", "you");
$mail->Body = $emailText;
      
if(!$mail->Send()) {
     echo "Mailer Error";
     echo $mail->ErrorInfo;
}       
else {
echo "success!";
}
0
skylabel
Asked:
skylabel
  • 3
  • 2
  • 2
  • +1
1 Solution
 
dr_dedoCommented:
your code looks fine to me, and blocking port 25 should not be an issue here. but try to use your full username
$mail->Username = "myusername@domain.com";  // SMTP username

0
 
skylabelAuthor Commented:
I did...but is this true?
If I'm able to send using outlook express, shouldn't it mean that php mailer should also work using the same smtp server?
Thanks
0
 
dr_dedoCommented:
yes, it should. Are you testing your sctript locally or on your server? try to test from the server itself
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
skylabelAuthor Commented:
I think I know the problem - I don't have the class file class.smtp.php, but it never showed an error message until I tried uploading it another server. Will post results!
0
 
kamermansCommented:
I send mail from phpmailer through my we host all the time and my ISP blocks port 25 - most webhosts have an alternate smtp port that you can use, mine is 777:

$mail->Host = "smtp.domain.com:777"; //specify SMTP host on alternate port
0
 
skylabelAuthor Commented:
Thanks for all the comments.

I don't quite understand this smtp thing. My ISP has blocked port 25, but I can still use my webhost's smtp right? So I just specify my webhosts smtp settings, is that correct?

Also, what actually happens when I don't specify a SMTP host? Isn't that being sent from my web host as well?

Thanks
0
 
dktuCommented:
use port which your Outlook Express is using
0
 
kamermansCommented:
Ok - if your ISP blocks traffic on port 25 AND your php script that is trying to send mail is on a computer that uses YOUR internet connection, then it will not be able to send mail using SMTP on port 25.  The difference is that with SMTP phpmailer will send the messages to the mailserver you specify and that mailserver will deliver them.  If you don't specify SMTP phpmailer will attempt to use your local mailserver - the one that's installed on your linux box by default (either sendmail or postfix) and that computer will work like a mail server, delivering the mail directly to it's recipients.  Does that help?

-Steve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now