Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Discussion on send smtp mail from godaddy server in php

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.60k
    Comment on it

    Hi Reader's,
    Welcome to FindNerd, today we are going to discuss on how to send SMTP mail from GoDaddy server in PHP.

    If you are developing any web application in PHP then, sometimes you are required to send emails in your PHP application.

    You can send email in your web application when any new user get registered in your web application or when user forgot the password then you can send him new password on his email.

    There are two methods for sending email PHPphp

    1-Mail - Send using PHP mail function.
    2-Smtp - Send using SMTP(simple mail transfer protocol).

    So, Simple Mail Transfer Protocol (SMTP)  is a best way to send email in php. It is a process of sending and receiving e-mail to and from users. It is very secure method compare to simple mail function.

    You can follow below steps for sending email on godaddy server

    So firstly you have to make array and define your message and randomly password like below example

    <?php
         $data_send = array();
         $data_send['body'] = '<p>Hi abc,</p><p> Please complete the verification by using the password below :- </p><p>Password: 123456</p><p>To change your password log in first, then go to the change password screen from the options menu</p><br><p>Regards ,<br> Mythanex </p>';
         $data_send['subject'] = "Verification Email";  // define subject here
         $data_send['to'] = "abc@gmail.com"; // define reciever email 
         $output = $this->send_mail($data_send); // call send_mail function()
    ?>

     

    After define array data you will configure your send_mail() and configure smtp detail.

    <?php
       public function send_mail($email_data = null) {
          $mail = new PHPMailer();
          $mail->IsSMTP();
          $mail->Host = "smtpout.secureserver.net"; //also tried "relay-hosting.secureserver.net"
          $mail->Username = "xyz@gmail.com"; /*define here your real email */
          $mail->Password = "XXXX"; /*define here  your real password*/
          $mail->FromName = "web";/* define here your heading name  */
          $mail->From = "noreply@example.com"; /* define here email from  which you to send mail  */
          $mail->SMTPAuth = true;
          $mail->Port = 80;
            
           /* Configure the address the email will be sent to */
           $mail->addAddress($email_data['to']);
           $mail->Subject = $email_data['subject'];
           /* This is forwarded through a GoDaddy forwarding account */
    
           $mail->Body    = $email_data['body'];
    
    
        if (!$mail->send()) {
             echo "Fail Error: "; // if email will not send then you will get failure message 
           } else {
             echo "Message sent!";// when email will send successfully
            }
        }
    
    ?>

    I hope this blog will help you to send SMTP mail by godaddy server.

     

 1 Comment(s)

  • Is this safe, placing your passwod for godaddy's email in a php form?

    Also, I get errors, and thus does not work for me:

    Parse error: syntax error, unexpected T_PUBLIC

    Remove public then

    Fatal error: Using $this when not in object context

    remove $this then

    Fatal error: Class 'PHPMailer' not found

    Guess I need yet another solution to sending mail via Godaddy hosting.
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: