Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email using phpmailer on GoDaddy hosting

Tags:

php

I'm trying to send a email using the GoDaddy but the problem is my code isn't working.

Do I need to configure something on GoDaddy? The idea is I have a customer and they have a gmail account. The site has a form and the customer needs to receive all the submitted contact information to their gmail account.

I have no idea how to do it and have tried for three days with no success.

This is the code that I'm using to send the emails to the account:

/* Instanciando as Bibliotecas Responsaveis pelo PHPMailer */
require_once '../PHPMailer/class.phpmailer.php';
require_once '../PHPMailer/class.smtp.php';


/* Instanciando a Classe de Email */
$email  = new PHPMailer();

/* Configurando o Email. */
$email->SMTPSecure   = "ssl";
$email->IsSMTP();
$email->SMTPAuth     = true;

$email->Host         = "smtpout.secureserver.net";
$email->Port         = 465;



$email->Username     = "[email protected]";
$email->Password     = "";
$email->IsHTML(true);


/* Configuracoes de quem Esta Mandando o Email. */
$email->SetFrom($_POST['txtEmail'], $_POST['txtName']);
$email->AddReplyTo($_POST['txtEmail'], $_POST['txtName']);
$email->From         = "[email protected]";
$email->FromName     = $_POST['txtName'];
$email->AddAddress('[email protected]');
$email->Subject      = 'Contact Us Email';
$email->Body         =  'Name : '           .$_POST['txtName'].             '<br/>'.
                        'Email : '          .$_POST['txtEmail'].            '<br/>'.
                        'Especialidade : '  .$_POST['txtEspecialidade'] .   '<br/>'.
                        'Phone : '          .$_POST['txtTelefone'].         '<br/>'.

                        'Message : '        .$_POST['txtComentario'];

/* Verificar se o Email foi Enviado com Sucesso */
if($email->Send()):
    $Mensagem = 'Email Enviado com Sucesso';
else:
    $Mensagem = 'Erro ao Enviar o Email '.$email->ErrorInfo;
endif;

/* Mostrar o Resultado. */
echo $Mensagem;

I'm sorry but it's in Portuguese. Thanks people.

like image 796
Ricardo Scarpim Avatar asked Dec 04 '22 09:12

Ricardo Scarpim


1 Answers

GoDaddy has several limitations for its shared-hosting plans.

If you're trying to send emails from the GoDaddy host, you'll need to use the following SMTP server:

relay-hosting.secureserver.net

Also, keep in mind that the GoDaddy SMTP servers are very busy, which means it might take some time until your email sent to its recipient.

Don't waste your time and try to configure other SMTP servers (Gmail etc) to handle your outgoing emails. GoDaddy has blocked this option and limited it only to the mentioned server above.

Read here: GoDaddy costumer service answer

like image 82
hrr Avatar answered Dec 20 '22 17:12

hrr