Hi,
I have been trying for a couple months now to gain basic email functionality in my web form. I've just downloaded and installed phpmailer and followed their tutorial. It all seems simple enough, but I keep getting the error Message was not sent.Mailer error: SMTP Error: The following SMTP Error: Data not accepted.testmail@yahoo.com

I was going to ask them for guidance but they have it clearly explained that only paying customers take a priority (fully understandable, they need to make a living). If someone out there has any experience with this program and can give me a little assistance I would REALL appreciate it!

Here is the code:

<?php

 require("class.phpmailer.php");  

 $mail = new PHPMailer();  

 $mail->IsSMTP();  // telling the class to use SMTP  
$mail->Host = "smtpout.secureserver.net"; // SMTP server $mail->From = "info@zenix.biz";
$mail->AddAddress("testmail@yahoo.com"); $mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50; if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
} ?>

    Thank you for replaying. Yes, I tried it and kept getting errors. I finally sought assistance and the only thing anyone would offer is for me to use this program or some other one, following the tutorials. I would love to utilize the built in mail() function, but I can't seem to get any help. Would YOU consider trying to assist me? I am new to this, but I am not so new that you're likely to become frustrated and consider me stupid (or any other similar, more polite adjective).

    I'd really like it very much if i could get help on some form of email function in my coding. Thanks again!

      What errors were you getting when using mail()?

      It is part of the PHP Core I thought so maybe someone here would be curious to see what is going wrong an be able to lead you into the right direction. I strongly suggest using their built in function and if you cannot for some reason get that to work then please post the problem here.

      Other people will have objections to using the built in mail function but if you are just trying to send email out from a form I personally think that is the easiest way.

      Post some errors so we can see what is exactly going on with you mail() function.

        Thank you for your apparent genuine concern. I appreciate it. found out this morning that I was using the wrong SMTP socket by my host. It looks as though I am almost there...just an inch more to go....but I am still hung up. My code is below:

        <?PHP
        /* Setup your Subject and Message Body */
        $subject='Testing PHP email';
        $body='Testing, testing';
        
        /* Specify your SMTP Server, Port and Valid From Address */
        ini_set("SMTP","hosting.secureserver.net");
        ini_set("sendmail_from","tester@test.biz");
        
        
        /* Additional Headers */
        $headers = "Cc:Real CC Name <here@therecom>\r\n";
        $headers .= "Bcc:Real BCC Name <this@that.com>\r\n";
        
        /* Try to send message and respond if it sends or fails. */
        if(mail ('ToDave <dave@yahoo.com>', $subject, $body, $headers )){
        echo "<h2>Your Message was sent!</h2>";
        }
        else{
        echo "<font color='red'><h2>Your Message Was Not Sent!</h2></font>";
        }
        exit;
        ?> 

        The error says:

        Warning: mail() [function.mail]: Failed to connect to mailserver at "hosting.secureserver.net" port 110, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\Apache Group\Apache2\htdocs\test\mail3.php on line 16
        Your Message Was Not Sent!

          I'm curious, My web host has me with IIS6, without php support. Would this make the emails fail?

            First of all, I would strongly suggest you use a more complex mail script than simply calling the mail function. Sending email by the mail() function alone has a set of security issues, one of which being that it's relatively easy for your form to be compromised and used to send spam (have had it happen to me personally).

            I would suggest you use the PHP Mailer Class (http://phpmailer.codeworxtech.com/) and configure it for SMTP. Authentication of an SMTP account will make sending of mail from your server considerably more secure than just calling the mail() function directly.

            Onto your IIS comment, do you use PHP elsewhere in your website? You said IIS6 without PHP support, but if you didn't have PHP support I wouldn't have expected it to actually process the PHP and give you a PHP error.

            That error is telling you that the port is set incorrectly. It could be that your server does not have SMTP configured for a default port or you inputted the wrong one. Check to see what port SMTP operates on and make sure that matches your configuration.

            If you don't have access to your php.ini file or simply don't want to mess with it, you can do the following at the top of your email script:

            ini_set("smtp_port", "YOURPORT");

            EDIT: Also, I just noticed that in your first example you haven't provided the script with the password to the email account. SMTP authentication will require the username and password for the account. If the script can't login to the mail server, it can't send your email.

              Thank you for your thought out reply. I appreciate it. My SMTP is configured for port 110, the php.ini file is also configured for 110. The errors I get are generated by the software on my personal computer. I have decided to learn php, having had some pretty good successes....along with the miserable failures. I'm getting there. Anyway, my host is Godaddy.com and when they told me what server to use for relaying they also explained that a user name and pw aren't required.

              I have attempted the phpmailer class with no success, but then I was also using the wrong SMTP server. I could try it again, but I keep getting conflicting thoughts about whether to use a third party class or simply the mail() function.

              I'll attempt the phpmiler again, I DO want to learn to implement php in a secure manner. Thanks again for your time!

                Having not read the PHPMailer documentation I may be wrong, but my understanding is that using SMTP authentication will require a username and password, and every instance of PHPMailer that I have operating is configured for SMTP with authentication through the email address/username and associated password. It sounds like godaddy is directing you on generic use of the mail() function, which does not require a username or password because it has no authentication, hence the security hole.

                  Thanks an awful lot for your rime and help. I'll see if I can get some help from Godaddy, as that seems to be the root of my problem.

                    a month later

                    Mike,
                    You mentioned that you use PHPMailer quite a bit. I'm am using it now and cannot get it to connect to any SMTP server. I use 1and1 to host my sites. I've tried connecting via smtp to comcast, 1and1 and Gmail with no success. Same problem: Cannot connect to server.

                    1and1 says that if I'm using the same authentication credentials in Outlook and PHPMailer and Outlook works but PHPMailer does not then it's a problem with PHPMailer. I'm getting no help from them. Since it works with you and everyone else the problem points back to 1and1 but they won't bother with it.

                    I was hoping you may have some insight as to what may be causing the problem. The script is very basic for, just trying to get it to work.

                    Have you seen this problem?
                    Do you know what else I can try?

                    I've tried with pop before smtp (does not work), smtp (does not work). Everything works if I do not use SMTP. Works great that way.

                    I really appreciate your time and any insight you can offer.

                      21 days later

                      Hi,

                      I don't know what you've decided but here is the smtp info for godaddy:
                      relay-hosting.secureserver.net

                      worked for my simple script

                        Write a Reply...