php mail() from godaddy server

前端 未结 3 760
悲&欢浪女
悲&欢浪女 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 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.

    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');
    

提交回复
热议问题