php mail() from godaddy server

前端 未结 3 757
悲&欢浪女
悲&欢浪女 2021-01-19 02:59

I\'m using godaddy for hosting my site and using default godaddy mail service. Now i want to sent email using php mail function to other email address from my 1 of my 15 em

相关标签:
3条回答
  • 2021-01-19 03:40

    Instead of using the mail() function, which just calls the OS mail function (i.e. sendmail), try something like SwiftMail (free PHP mail library). It support many different ways of sending mail, including logging into a mail account and sending email, just like you would do from your own computer. You could even send email from a gmail account if you wanted.

    http://swiftmailer.org/

    0 讨论(0)
  • 2021-01-19 03:54

    The PHP mail function uses the mailserver configured for that webhost. You can't change that. Since godaddy controls the mailserver they control what headers it sends. You could try inserting a custom From header but I doubt that will work. It will either get modified, flagged as spam, or rejected.

    If you have 15 accounts at godaddy, perhaps it's time to look for a more serious hosting solution?

    0 讨论(0)
  • 2021-01-19 04:02

    I am using godaddy hosting . Just keep some fields blank and send mail it will work . please see below code its working for me.

    <?php
    include("class.phpmailer.php");
    function sendMail($address,$username,$body){
                $mail = new PHPMailer();
                $mail->IsSMTP(); // telling the class to use SMTP
                //$mail->Host       = "smtp.gmail.com"; // SMTP server
                $mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                    // 1 = errors and messages
                                                                               // 2 = messages only
                // $mail->SMTPAuth   = true;                  // enable SMTP authentication
                // $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
                // $mail->Host       = "smtp.gmail.com";      // sets  as the SMTP server
                // $mail->Port       = 465;                   // set the SMTP port for the server
                // $mail->Username   = "xyz@gmail.com";  // username
                // $mail->Password   = "test121232";            // password
    
                $mail->SetFrom('contact@example.co.in', 'Contact');
    
                $mail->Subject    = "Enquiry for tour and travels package";
    
    
    
                $mail->MsgHTML($body);
    
                $address = $address;
                $mail->AddAddress($address, $username);
                $mail->AddCC('contact@example.co.in');
    
                if(!$mail->Send()) {
                echo "Mailer Error: " . $mail->ErrorInfo;
                } else {
                echo "Message sent!";
                }
    }
    
    ?>
    

    just changed from email address, so you can send mail through this email id.

    $mail->SetFrom('youremail@example.co.in', 'Contact');
    
    0 讨论(0)
提交回复
热议问题