Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 511
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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