Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php PEAR smtp

Posted on 2012-04-01
10
Medium Priority
?
469 Views
Last Modified: 2012-04-01
I have managed to get my PHP email application working with the PEAR installation on my small business server 2003.
Problem is that it will not work on another server even though all the settings appear correct
The data is not being sent.
Can someone please tell me where on earth the SMTP values are being taken from in the PEAR application (Mail.php)
0
Comment
Question by:doctorbill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 7

Assisted Solution

by:ZShaver
ZShaver earned 1336 total points
ID: 37793012
check php.ini, usually found at the installation path of PHP or in c:\windows

if you can't find it make a php script with:

<?php
phpinfo();
?>

which will give u a diagnostic page with all of the loaded modules, their settings (including the SMTP settings), aswell as the location of php.ini so you can change this value.
0
 
LVL 7

Accepted Solution

by:
ZShaver earned 1336 total points
ID: 37793019
also u can specify a smtp server in the script itself and pear will connect to it
example:

<?php 
    $from_name = "Zach Shaver"); 
    $to_name = "Experts Exchange User"); 

    $From = "From: ".$from_name." <fromaddress@domain.com>"; 
    $To = "To: ".$to_name." <toaddress@domain.com>"; 

    $recipients = "toaddress@domain.com"; 
    $headers["From"] = $From; 
    $headers["To"] = $To; 
    $headers["Subject"] = $subject; 
    $headers["Reply-To"] = "reply@address.com"; 
    $headers["Content-Type"] = "text/plain"; 
    $headers["Return-path"] = "returnpath@address.com"; 
     
    $smtpinfo["host"] = "smtp.server.com"; 
    $smtpinfo["port"] = "25"; 
    $smtpinfo["auth"] = true; 
    $smtpinfo["username"] = "smtp_user"; 
    $smtpinfo["password"] = "smtp_password"; 

    $mail_object =& Mail::factory("smtp", $smtpinfo); 

    $mail_object->send($recipients, $headers, $mailmsg); 
?> 

Open in new window

0
 

Author Comment

by:doctorbill
ID: 37793021
So the PEAR mail.php takes smtp settings from the php.ini file ?
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!

 

Author Comment

by:doctorbill
ID: 37793055
I tried this with my own authsmtp settings:

$smtpinfo["host"] = "smtp.server.com";
    $smtpinfo["port"] = "25";
    $smtpinfo["auth"] = true;
    $smtpinfo["username"] = "smtp_user";
    $smtpinfo["password"] = "smtp_password";

still not working.
0
 
LVL 35

Assisted Solution

by:gr8gonzo
gr8gonzo earned 664 total points
ID: 37793170
Hi doctorhill,

PHP will do its best to figure out the mail host on its own, although it will read the "SMTP" setting from your ini file if you're running on Windows. That said, if you tried to specify the SMTP server manually and it still didn't work, then that makes me wonder if your script is running on a computer that is using a typical residential or cheap business internet connection. A lot of internet providers try to block any outbound email requests that are not routed through their own mail servers. For example, Cox Cable will block any communications on port 25 except for those going to their own SMTP servers (like smtp.west.cox.net).

The reason for this is because of all those viruses about 5-10 years ago that were spreading by emailing themselves out directly to people. So by blocking all mail unless it goes through their own mail servers, internet providers can render those worms/viruses useless and can prevent newly-infected computers from spreading them further (and also limit the misuse/abuse of their own bandwidth).

The downside to this is that a provider can't distinguish between a worm trying to email itself out and a PHP script that is trying to connect to a valid, external mail server for a legitimate reason, so everything gets blocked. If your script is going to stay hosted on that network connection, try changing your SMTP host to whatever you use for your personal email on that internet connection (and don't use auth unless you also use it for your personal email).
0
 

Author Comment

by:doctorbill
ID: 37793210
I have tried using my "authsmtp" account which is usually  allowed from any network. The email is still not being sent
0
 

Author Closing Comment

by:doctorbill
ID: 37793484
Certainly helped me to go forward
0
 
LVL 7

Expert Comment

by:ZShaver
ID: 37793630
see if you can connect through telnet to the SMTP server from the remote machine

eg...
telnet smtp.company.com 25
EHLO remotehost.company.com


if the screen stays blank or if telnet won't connect, it's a connectivity issue, not an authentication issue.
0
 
LVL 7

Expert Comment

by:ZShaver
ID: 37793632
similarly, you can install a mail client on the "remote" machine...
and verify you can send email from the mail client...

don't stress over doing it in PHP until you verify it's actually working as intended.
0
 
LVL 7

Expert Comment

by:ZShaver
ID: 37793633
you already accepted my solution but i figured i'd give u those tips anyways lol
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question