Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
688 views
in Technique[技术] by (71.8m points)

php - Send email using phpmailer on GoDaddy hosting

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@example.com";
$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@example.com";
$email->FromName     = $_POST['txtName'];
$email->AddAddress('email@example.com');
$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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...