SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 39
  1. #1
    SitePoint Member
    Join Date
    Feb 2003
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    advanced email in php

    newbie to php!
    i have just started kevins tutorial on advanced email in php, i confused about this line though

    Setup for Windows systems
    SMTP = smtp.my.isp.net


    i have php installed on my machine at home, along with the apache web server,


  2. #2
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by peegee
    newbie to php!
    i have just started kevins tutorial on advanced email in php, i confused about this line though

    Setup for Windows systems
    SMTP = smtp.my.isp.net


    i have php installed on my machine at home, along with the apache web server,

    It means that in you php.ini file there are a couple of lines to deal with the emails and you need to give a proper smtp server in order to send emails

    it looks like this
    [mail function]
    ; For Win32 only.
    SMTP = 172.256.0.1 // replace this number with your smtp server.

    I hope it helps

  3. #3
    SitePoint Member
    Join Date
    Feb 2003
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for replay:

    do i change sendmail_from to my own email address and will this cause the emails to be sent to me.

    is it o.k to leave smpt to "localhost"

  4. #4
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Ottawa, ON Canada
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php.ini & SMTP= - how to supply username & password to SMTP server?

    Great article. Two comments:

    1) Instructions for setting php.ini sendmail_from= and SMTP= don't account for the need to authenticate. How do I configure PHP to send a username / password to my SMTP server when I call php.mail()?

    2) Link on article page 1 "By Kevin Yank" href=javascript:feedbackwindow('/feedback/679'); causes "Error on page." message on status bar of Microsoft Internet Explorer 6.

  5. #5
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by peegee

    is it o.k to leave smpt to "localhost"
    Only if you have a SMTP server installed locally, or if you don't intend to send email with your php script (which is unlikely, considering you're doing the tutorial)

    If you have an ISP, you can replace that with your ISP's SMTP server like rafaes18 said, or try installing your own SMTP server locally (WinXP comes with a SMTP in the IIS suite)

  6. #6
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by redemption
    If you have an ISP, you can replace that with your ISP's SMTP server like rafaes18 said, or try installing your own SMTP server locally (WinXP comes with a SMTP in the IIS suite)
    Any alternatives if someone doesnt like IIS?

  7. #7
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by astericks
    Any alternatives if someone doesnt like IIS?
    I highly recommend Argosoft Mail Server
    http://www.argosoft.com

    They have a freeware version that only does one domain, but it does (i think) an unlimited amount of users. They also have another version that supports an unlimited amount of domains and users, as well as mailing lists, word filtering, plugins and web mail. The pro version is awesome and was only like $90
    There is also a great mailfilter plugin for it called MailFilter Pro
    http://www.sssolutions.net
    It lets you filter spam, viruses or anything else you want. It's an awesome tool.

    And no, I don't work for either one of these companies

  8. #8
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by john-m-calvert
    How do I configure PHP to send a username / password to my SMTP server when I call php.mail()?
    not that i know of.

    anybody know if you can do something if your SMTP requires authentication?
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  9. #9
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DR_LaRRY_PEpPeR
    not that i know of.

    anybody know if you can do something if your SMTP requires authentication?
    You can run your own mail server
    We are using the Argosoft mail server and we have SMTP Authentication turned on. But since the php mail() function doesn't send user/pass, in the argosoft setup, i set 127.0.0.1 as a trusted IP address, so it won't need to auth. And if you wanted to, you could just install argosoft to use it as a relay. It has a built in smart server, so you can tell it to send all of the mail that it receives, to your ISPs mail server if you want.

    So a work-around would be to install argosoft without SMTP authentication, tell php to use argosoft as your SMTP server, and tell argosoft to relay all mail through your ISPs smtp server, because you can give argosoft your ISP user/pass and it will authenticate. So it's like a middle man.

    I don't know for sure, but I would assume you could use any other mail server that supports "smart server" as a middle man.

  10. #10
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sojomy
    You can run your own mail server
    of course you can. i meant beyond doing that, but i'm sure there's no way for PHP itself to send the user/pass...

  11. #11
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DR_LaRRY_PEpPeR
    of course you can. i meant beyond doing that, but i'm sure there's no way for PHP itself to send the user/pass...

    digging though the source , it would be really easy to add SMTP authentication to the mail() function , but that would require you keeping your SMTP details in plain text in the php.ini or supplying them every time you used mail.... still can't see why it has not been implemented though ?

    I tried duplicating the mail() function as a seperate dll/module for windows but it was more work than my C is upto at the moment

  12. #12
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by astericks
    Any alternatives if someone doesnt like IIS?
    PostCast Server - http://www.postcastserver.com/

    I didn't like it though because it was slow, and didn't manage to get it to work across different accounts. I only recommend IIS because, if you have WinXP, it seems to be the least difficult to install and setup and most efficient.

  13. #13
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DR_LaRRY_PEpPeR
    of course you can. i meant beyond doing that, but i'm sure there's no way for PHP itself to send the user/pass...
    I forgot, Uebimiau (the web mail client) DOES do SMTP authentication. Our mail server has it enabled, and I can send mail from the web mail. And as I watch the log, I see it sending the user/pass for SMTP Authentication.

    http://www.uebimiau.sili.com.br/

    Download the script and look in the /inc/class.smtp.php file
    Here's some key parts (the file is large, so i won't post it all).

    PHP Code:
    <?
    class phpmailer {
     function 
    UseAuthLogin($user,$pass) {
      
    $this->blUseAuthLogin true;
      
    $this->AuthUser $user;
      
    $this->AuthPass $pass;
     }
     
     
      if(
    $this->blUseAuthLogin) {
       if(!
    $smtp->AuthHello($this->Helo,$this->AuthUser,$this->AuthPass)) {
          
    $this->error_handler("SMTP Error: Invalid username/password");
          return 
    false;
       }
      } else
       
    $smtp->Hello($this->Helo);

     
        function 
    AuthHello($host="",$user="",$pass="") {
            
    $this->error null# so no confusion is caused
            
    if(!$this->connected()) {
                
    $this->error = array(
                        
    "error" => "Called Hello() without being connected");
                return 
    false;
            }
            
    # if a hostname for the HELO wasn't specified determine
            # a suitable one to send
            
    if(empty($host)) {
                
    # we need to determine some sort of appopiate default
                # to send to the server
                
    $host "localhost";
            }
            
    $this->send_line("EHLO ".$host);
            
    $rply $this->get_lines();
            
    $code substr($rply,0,3);
            if(
    $code != 250) {
                
    $this->error =
                    array(
    "error" => "EHLO not accepted from server",
                          
    "smtp_code" => $code,
                          
    "smtp_msg" => substr($rply,4));
                return 
    false;
            }
            
    $this->helo_rply $rply;
            
    $this->send_line("AUTH LOGIN");
            
    $rply $this->get_lines();
            
    $code substr($rply,0,3);
            if(
    $code != 334) {
                
    $this->error =
                    array(
    "error" => "AUTH LOGIN not accepted from server",
                          
    "smtp_code" => $code,
                          
    "smtp_msg" => substr($rply,4));
                return 
    false;
            }
            
    $this->send_line(base64_encode($user));
            
    $rply $this->get_lines();
            
    $code substr($rply,0,3);
            if(
    $code != 334) {
                
    $this->error =
                    array(
    "error" => "USER not accepted from server",
                          
    "smtp_code" => $code,
                          
    "smtp_msg" => substr($rply,4));
                return 
    false;
            }
            
    $this->send_line(base64_encode($pass));
            
    $rply $this->get_lines();
            
    $code substr($rply,0,3);
            if(
    $code != 235) {
                
    $this->error =
                    array(
    "error" => "PASSWORD not accepted from server",
                          
    "smtp_code" => $code,
                          
    "smtp_msg" => substr($rply,4));
                return 
    false;
            }
            return 
    true;
        }
    }
    ?>

    I'm still an OOP virgin, so I don't understand most of that. But I hope it helps someone else. Especially those who have, so many times, helped me.

    Also, in case you people didn't know it, when you post code in the
    [ PHP ] and [ /PHP ]
    tags, if you include enclose the code in
    <? and ?>
    tags, it won't put that vBulletin "BEGIN__VBULLETIN__CODE__SNIPPET" crap in your post.

  14. #14
    SitePoint Member
    Join Date
    Mar 2003
    Location
    aus
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can i change " sendmail_from " to my own email address such as anz@yahoo.com ?

    thanks for reading,

  15. #15
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anz
    can i change " sendmail_from " to my own email address such as anz@yahoo.com ?
    yes, i think you can. try it. don't forget to restart your Web server after making the change.

  16. #16
    SitePoint Member
    Join Date
    May 2003
    Location
    SoCal
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How do I restrict file types?

    How do I go about restricting the file types to images only?
    Oh, and how do limit the attachment file size?

    Thanks in advance,

    Jonathan
    Last edited by Jonathan_Beni; May 5, 2003 at 16:44.

  17. #17
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    www.mailenable.com << Great Mail Server
    pear.php.net << The SMTP Mail Class using Net_Socket supports SMTP Authentication.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  18. #18
    SitePoint Member
    Join Date
    May 2003
    Location
    Tuscany,Italy
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Empty attachments?

    Hi,

    My first post on this forum. I found the article really useful and used it to create a page to send an email with details from a form and an attached file.

    It worked fine on my own host (Unix/Apache/PHP4.1) but when I moved it over to the clients host (Win2k/IIS/PHP4.1.2) the attachments got through but were empty.

    Something to do with the PHP.INI perhaps? SMTP setup?

    Any ideas?

    Thanks

    Mark

    UPDATE - MYSTERY SOLVED:

    The permissions on the host weren't properly set. Anyone else that gets this problem should check the permissions and maybe the PHP.INI
    Last edited by Happyworm; Jun 17, 2003 at 06:06.

  19. #19
    SitePoint Member
    Join Date
    May 2003
    Location
    Norway
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jonathan_Beni
    How do I go about restricting the file types to images only?
    Oh, and how do limit the attachment file size?

    Thanks in advance,

    Jonathan
    Anyone know how to do this? And does it work whit phph 4.3.1?
    Regards
    Klaus Andreassen
    Norway

  20. #20
    SitePoint Member Iceflow's Avatar
    Join Date
    Nov 2003
    Location
    somewhere
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops
    Last edited by Iceflow; Dec 8, 2003 at 09:25.

  21. #21
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Earth
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi iceflow, welcome to php

    make sure your php.ini has the SMTP settings correctly, and try to send simple email to yourself mail('you@youraddress.com', 'test', 'test'); and see what happens.

    If you use php as ISAPI you might need to restart IIS to reload php.ini
    http://www.quadrahosting.com/
    Multi Domain Web Hosting service for newbie and experienced developers

  22. #22
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Earth
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Klausre
    Anyone know how to do this? And does it work whit phph 4.3.1?
    Quote Originally Posted by Jonathan_Beni
    How do I go about restricting the file types to images only?
    Oh, and how do limit the attachment file size?
    Hi, normally you'd have to check this in your code before adding the attachment to your email message. If you can show us your code we'll try to help.
    http://www.quadrahosting.com/
    Multi Domain Web Hosting service for newbie and experienced developers

  23. #23
    SitePoint Member Iceflow's Avatar
    Join Date
    Nov 2003
    Location
    somewhere
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JimQH
    Hi iceflow, welcome to php

    make sure your php.ini has the SMTP settings correctly, and try to send simple email to yourself mail('you@youraddress.com', 'test', 'test'); and see what happens.

    If you use php as ISAPI you might need to restart IIS to reload php.ini
    It was a long weekend
    I forgot to change my smtp setting back in my php.ini when i got into the office this morning...
    works 100% now...hehe....what a wally! *bow*

    Laterz,

    Iceflow

  24. #24
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    maine
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    I can get the mail function to work properly when I load the page to my site's server, but can't get it to work on my own computer (I have PHP 4.3.4 and have a Mac). PHP works on my computer for everything else that I've tried (with the exception of the PHP Gallery article on Sitepoint...).
    I've checked my php.ini settings and everything seems kosher.
    Anyone have any ideas?
    thanks, and cheers.

    the code for mail.php:
    <?php

    $to="me@mydomain.com";
    $subject="testing uh hu";
    $message="sheesh, it worked";

    if (@mail($to, $subject, $message))
    {
    echo ('<p>Mail sent successfully.</p>');
    }
    else
    {
    echo ('<p>Mail could not be sent.</p>');
    }


    ?>

  25. #25
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imagine8
    I've checked my php.ini settings and everything seems kosher.
    Anyone have any ideas?
    Do you have an MTA set up on your system?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •