Tengo una duda al usar PHPMailer, creo que estoy colocando mal la información, porque no me llegan correos desde un formulario que tengo.
Es una forma de registro a un sitio, el usuario solamente ingresa lo siguiente:
Usuario -> Correo electrónico válido.
Password -> Un password con ciertas características.
En PHPMailer, se deben configurar ciertos parámetros de acuerdo a tu servidor SMTP. Creo que es aquí donde me estoy confundiendo al meter los datos.
Por ejemplo, yo tengo un servidor con lo siguiente:
Host: dominio.jobs
Puerto SMTP: 26
Username: [email protected]
Password: C0nt4ct0$
Tengo el cuerpo del mail en una variable llamada $shtml:
Código PHP:
   $shtml = ' 
    <div style="font-family:"Arial"; width:80%; margin:0 auto;">
        <table width="100%" border="0">
          <tr>
            <td align="left" height="auto"><a href="http://dominio.jobs" target="_blank"><img src="http://dominio.jobs/img/logos/logo.png" alt="" title="dominio.jobs" /></a></td>
          </tr>
          <tr>
            <td align="left" style="font-size:18px; color:#f7941e; font-weight:bold;" height="50px">Bienvenido a dominio.jobs:</td>
          </tr>
          <tr>
            <td align="left" height="50px">
                Tu cuenta se creo con el correo: ' .  $email . '
                <br /><br />
                Es necesario que la valides con el código de verificación que te estamos proporcionando.
                <br />
                Cópialo y pégalo en el paso 2 de tu registro y dale click en <strong>Activar</strong> para finalizar el proceso.
            </td>
          </tr>
          <tr>
            <td align="center" height="50px">
                <strong>Código de verificación:</strong>
                <br />
                ' . $codigo . '
                <br /><br />
                <strong>o dirígete a la siguiente liga</strong>
                <br /><br />
                <a href="http://dominio.jobs/account-user.php?register=verify&email=' . $email . '&code=' . $codigo . '">code=' . $codigo . '</a>
                <br /><br />                
            </td>
          </tr>
          <tr>
            <td align="left" height="50px">
                Este código de verificación sólo puede ser utilizado el día en que generaste tu registro, así que por favor concluye el proceso lo más pronto posible.
                <br /><br />
                <strong>Dominio.jobs</strong>, es la ....
                <br /><br />
                Para cualquier duda o aclaración, por favor envíanos un correo a [email protected] comentándonos el problema que se haya presentado en tu registro.
                <br /><br />
            </td>
          </tr>
          <tr>
            <td align="left" height="50px" style="border-top:2px solid #f7941e; color:#4D4A4A; font-size:10px; padding:15px 0;">
                Este email fue enviado desde el sitio de <strong>dominio.jobs</strong> debido a que realizaste tu registro en el sistema. Asegúrate de marcarlo como correo deseado y así evitar que 
                pueda ser enviado a tu carpeta de Spam. 
                <br /><br/>
                <strong>© 2015, Dominio.jobs Todos los Derechos Reservados.</strong>
                <br />
                <a href="http://dominio.jobs.com/privacy-policy.php" target="_blank">Políticas de Privacidad</a> | <a href="http://dominio.jobs/terms-and-conditions.php" target="_blank">Términos y Condiciones</a>
            </td>
          </tr>
        </table>
    </div>
    '; 
    Ahora, tengo el código de PHPMailer:
Código PHP:
   require("class.phpmailer.php");
 
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = preg_replace('/[]/','',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mydomain"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mydomin"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "me@mydomain"; // SMTP account username
$mail->Password = "mySMTPpassword"; // SMTP account password
$mail->SetFrom('me@mydomain', 'Mailer Elim');
$mail->AddReplyTo("me@mydomain","Elim Qiu");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "him@hisdomain";
$mail->AddAddress($address, "HisFirst HisLast");
$mail->AddAttachment("infinite.gif"); // test attachment I added to /mailer
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
} 
    Código PHP:
   $body = file_get_contents('contents.html');  -> No lo usaría
$body = preg_replace('/[]/','',$body); -> No lo usaría
$body = $shtml; 
    Código PHP:
   $mail->Host = "mydomain"; quedaría como $mail->Host = "smtp.dominio.jobs";
$mail->Port = 25; En este caso, mi puerto es 26, pero no sé si debo cambiarlo o dejarlo como esta.
$mail->Username = "me@mydomain"; quedaría como $mail->Username = "[email protected]";
$mail->Password = "mySMTPpassword"; quedaría como $mail->Password = "C0nt4ct0$"; 
    Código PHP:
   $mail->SetFrom('me@mydomain', 'Mailer Elim');
$mail->AddReplyTo("me@mydomain","Elim Qiu"); 
    Código PHP:
   $mail->SetFrom('[email protected]', 'X Nombre');
$mail->AddReplyTo("[email protected]","Y nombre"); 
    Código PHP:
   $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; quedaría como $mail->Subject = "Mi subject";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test No lo usaría 
    Código PHP:
   $address = "him@hisdomain";
$mail->AddAddress($address, "HisFirst HisLast"); 
    Código PHP:
   $address = $email;
$mail->AddAddress($address, "Sr. Z"); 
    De antemano, les agradezco por sus comentarios.
Saludos!!
 
 




