I am trying to sent a email to a already existing email address using STMP Server on a Wamp Server host locally. Here with smtp.gmail.com on port 465, the page freeze and loads indefinitely. All the variables are good, I didn't put every of them here.
I try smtp.live.com but I got "Client was not authenticated to send anonymous mail" while I gave the correct logins. I don't know the name of the internet provider (homework context) I cannot use the SendEmail solution or any other plug-ins in the context of my homework. I hide the password for oblivious reasons in the code, but it won't work even with the correct one.
if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $mail)) // On filtre les serveurs qui rencontrent des bogues.
{
$passage_ligne = "\r\n";
}
else
{
$passage_ligne = "\n";
}
//=====Création de la boundary
$boundary = "-----=".md5(rand());
//==========
//=====Création du header de l'e-mail.
$header = "From: \"ECE Amazon\"<ece20192@gmail.com>".$passage_ligne;
$header.= "Reply-to: \"ECE Amazon\" <ece20192@gmail.com>".$passage_ligne;
$header.= "MIME-Version: 1.0".$passage_ligne;
$header.= "Content-Type: multipart/alternative;".$passage_ligne." boundary=\"$boundary\"".$passage_ligne;
//==========
//=====Création du message.
$message = $passage_ligne."--".$boundary.$passage_ligne;
//=====Ajout du message au format texte.
$message.= "Content-Type: text/plain; charset=\"ISO-8859-1\"".$passage_ligne;
$message.= "Content-Transfer-Encoding: 8bit".$passage_ligne;
$message.= $passage_ligne.$message_txt.$passage_ligne;
//==========
$message.= $passage_ligne."--".$boundary.$passage_ligne;
//=====Ajout du message au format HTML
$message.= "Content-Type: text/html; charset=\"ISO-8859-1\"".$passage_ligne;
$message.= "Content-Transfer-Encoding: 8bit".$passage_ligne;
$message.= $passage_ligne.$message_html.$passage_ligne;
//==========
$message.= $passage_ligne."--".$boundary."--".$passage_ligne;
$message.= $passage_ligne."--".$boundary."--".$passage_ligne;
//==========
//=====Envoi de l'e-mail.
ini_set("SMTP", "smtp.gmail.com");
ini_set("smtp_port","465");
ini_set("default_domain", "smtp.gmail.com");
ini_set("force_sender", "ece20192@gmail.com");
ini_set("sendmail_from", "ece20192@gmail.com");
//ini_set("auth_username", "ece20192@gmail.com");
//ini_set("auth_password", "");
mail($mail,$sujet,$message,$header);
//==========
The client is to supposed to received a email on his email adress with a short message. The SMTP server is supposed to accepted by request for sending an email.