I want to use the mail function to send out automated emails once an user has filled out some forms to different parties. But, my pop3 mail server requires a login and password. I didnt see in the documentation from php.net anywhere about setting the password and login. I set the server in my php.ini file. I did read that i might need to do socket programming and have a direct connection with the mail server but this seems like a very difficult thing to do. I know with other command line mailers that you can fill in the login, password, and server from the execution line? am i just missing something or do i have to do socket programming. and if i do socket programming how hard is it? o, i just realize i can do exec from php to run a command line mailer... i guess that would be another resort but i really like to mail it from the php mailer if possible to minimize installation on the eventual server of the website i am building.

O.o" i wrote a lot

    Hi there,
    first of all: POP3 is something you use, when you receive mail - not when you are sending mail.

    There shouldn't be any problems using the mail() function. I have done it without any special arrangements. When you are sending mails, you are using an smtp-server, that relays your mail further on in the system and this would typically be the one you are using under normal circumstances (like from Outlook Express under windows). So give it a try!

    Enjoy!

      are you sure? this is from an university so everything is encrypted and passwords and user names are required for most things. I tried sending mail to myself and i get an undeliverable memo from the server. I used cmd line mailers before and they needed passwords and usernames too...

        Well, of course I don't know, if you have any special security issues in your case.

        The background for my answers relates to sending mail from a local setup of PHP/Apache as well a remote setup of the same on the web hosting solutions I'm using. Basically, there should be no reason for supplying passwords and user-ids when sending a mail.

        What does the "undeliverable memo" say?

          does the local machine that your mail.php page resides on have an smtp server like Sendmail for nix, mailtraq for win, etc... or are you trying to use an external smtp server, cuz some smtp servers, as in my hosts setup, require authentication before an email will be sent

            umm... the mail.php will be running off a windows 2000 machine. I have a command line mailer for it. And I do need the authentication before the mail can be sent. Otherwise I get an error. I tried simple mailers without authentication information being sent to the mail servers and it always ends up not working. The same happened with the php mailer. I did look extensively into the mailer for php and it seems that I might need to do socket programming and communicate directly to the mail server which i am sure my school will not let me do. so is there some configuration i missed in my php.ini or whereever that i can set up the authentication information?

            sorry, i cant get that email again right now. but it was a return of mail; recipient not found kinda response. I debug by sending mail to myself through my server.

              hey thank you. both of you for heping out. i will look at this right after i work with this authentication ldap module thingy for apache2...

              best,

              bakaneko

                3 months later

                require("class.phpmailer.php");

                $mail = new PHPMailer();

                $mail->IsSMTP(); // send via SMTP
                $mail->Host = "smtp1.site.com;smtp2.site.com"; // SMTP servers
                $mail->SMTPAuth = true; // turn on SMTP authentication
                $mail->Username = "jswan"; // SMTP username
                $mail->Password = "secret"; // SMTP password

                $mail->From = "from@email.com";
                $mail->FromName = "Mailer";
                $mail->AddAddress("josh@site.com","Josh Adams");
                $mail->AddAddress("ellen@site.com"); // optional name
                $mail->AddReplyTo("info@site.com","Information");

                $mail->WordWrap = 50; // set word wrap
                $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
                $mail->AddAttachment("/tmp/image.jpg", "new.jpg");
                $mail->IsHTML(true); // send as HTML

                $mail->Subject = "Here is the subject";
                $mail->Body = "This is the <b>HTML body</b>";
                $mail->AltBody = "This is the text-only body";

                if(!$mail->Send())
                {
                echo "Message was not sent <p>";
                echo "Mailer Error: " . $mail->ErrorInfo;
                exit;
                }

                echo "Message has been sent";

                Download

                I copied it from phpmailer.sourceforge.net

                  Write a Reply...