-PHPMailer - SMTP (Gmail) advanced test
-
-
+
+ PHPMailer - SMTP (Gmail) advanced test
+
+
+ IsSMTP(); // telling the class to use SMTP
-$mail->IsSMTP(); // telling the class to use SMTP
-
-try {
- $mail->Host = "mail.yourdomain.com"; // SMTP server
- $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
- $mail->SMTPAuth = true; // enable SMTP authentication
- $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
- $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
- $mail->Port = 465; // set the SMTP port for the GMAIL server
- $mail->Username = "yourusername@gmail.com"; // GMAIL username
- $mail->Password = "yourpassword"; // GMAIL password
- $mail->AddAddress('whoto@otherdomain.com', 'John Doe');
- $mail->SetFrom('name@yourdomain.com', 'First Last');
- $mail->AddReplyTo('name@yourdomain.com', 'First Last');
- $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
- $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
- $mail->MsgHTML(file_get_contents('contents.html'));
- $mail->AddAttachment('images/phpmailer.gif'); // attachment
- $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
- $mail->Send();
- echo "Message Sent OK\n";
-} catch (phpmailerException $e) {
- echo $e->errorMessage(); //Pretty error messages from PHPMailer
-} catch (Exception $e) {
- echo $e->getMessage(); //Boring error messages from anything else!
-}
-?>
-
-
+ try {
+ //$mail->Host = "mail.yourdomain.com"; // SMTP server
+ $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
+ $mail->SMTPAuth = true; // enable SMTP authentication
+ $mail->SMTPSecure = "tls"; // sets the prefix to the servier
+ $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
+ $mail->Port = 587; // set the SMTP port for the GMAIL server
+ $mail->Username = "username@gmail.com"; // GMAIL username
+ $mail->Password = "password"; // GMAIL password
+ $mail->AddAddress('Recipient@example.com', 'Recipient Name');
+ $mail->SetFrom('Sender@example.com', 'Sender Name');
+ //$mail->AddReplyTo('name@yourdomain.com', 'First Last');
+ $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
+ $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
+ $mail->MsgHTML(file_get_contents('contents.html'));
+ $mail->AddAttachment('images/phpmailer.gif'); // attachment
+ $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
+ $mail->Send();
+ echo "Message Sent OK\n";
+ } catch (phpmailerException $e) {
+ echo $e->errorMessage(); //Pretty error messages from PHPMailer
+ } catch (Exception $e) {
+ echo $e->getMessage(); //Boring error messages from anything else!
+ }
+ ?>
+
diff --git a/examples/test_smtp_gmail_basic.php b/examples/test_smtp_gmail_basic.php
index 49807833..5cd0ae05 100644
--- a/examples/test_smtp_gmail_basic.php
+++ b/examples/test_smtp_gmail_basic.php
@@ -1,59 +1,58 @@
-
-PHPMailer - SMTP (Gmail) basic test
-
-
+
+ PHPMailer - SMTP (Gmail) basic test
+
+
-IsSMTP(); // telling the class to use SMTP
-$mail->Host = "mail.yourdomain.com"; // 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->SMTPSecure = "ssl"; // sets the prefix to the servier
-$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
-$mail->Port = 465; // set the SMTP port for the GMAIL server
-$mail->Username = "yourusername@gmail.com"; // GMAIL username
-$mail->Password = "yourpassword"; // GMAIL password
+ $mail->IsSMTP(); // telling the class to use SMTP
+ $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
+ // 1 = errors and messages
+ // 2 = messages only
+ $mail->SMTPAuth = true; // enable SMTP authentication
+ $mail->SMTPSecure = "tls"; // sets the prefix to the servier
+ $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
+ $mail->Port = 587; // set the SMTP port for the GMAIL server
+ $mail->Username = "yourusername@gmail.com"; // GMAIL username
+ $mail->Password = "yourpassword"; // GMAIL password
-$mail->SetFrom('name@yourdomain.com', 'First Last');
+ $mail->SetFrom('sender@example.com', 'First Last');
-$mail->AddReplyTo("name@yourdomain.com","First Last");
+ $mail->AddReplyTo("reply-to@example.com","First Last");
-$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
+ $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
-$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
+ $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-$mail->MsgHTML($body);
+ $mail->MsgHTML($body);
-$address = "whoto@otherdomain.com";
-$mail->AddAddress($address, "John Doe");
+ $address = "recipient@example.com";
+ $mail->AddAddress($address, "Recipient Name");
-$mail->AddAttachment("images/phpmailer.gif"); // attachment
-$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
+ $mail->AddAttachment("images/phpmailer.gif"); // attachment
+ $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
-if(!$mail->Send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
-} else {
- echo "Message sent!";
-}
+ if(!$mail->Send()) {
+ echo "Mailer Error: " . $mail->ErrorInfo;
+ } else {
+ echo "Message sent!";
+ }
-?>
+ ?>
-
+
diff --git a/language/phpmailer.lang-es.php b/language/phpmailer.lang-es.php
index 7b887f0a..b81520f2 100644
--- a/language/phpmailer.lang-es.php
+++ b/language/phpmailer.lang-es.php
@@ -3,23 +3,24 @@
* PHPMailer language file: refer to English translation for definitive list
* Spanish version
* Versión en español
+* Edited by Matt Sturdy - matt.sturdy@gmail.com
*/
$PHPMAILER_LANG['authenticate'] = 'Error SMTP: No se pudo autentificar.';
-$PHPMAILER_LANG['connect_host'] = 'Error SMTP: No puedo conectar al servidor SMTP.';
+$PHPMAILER_LANG['connect_host'] = 'Error SMTP: No se pudo conectar al servidor SMTP.';
$PHPMAILER_LANG['data_not_accepted'] = 'Error SMTP: Datos no aceptados.';
-//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['empty_message'] = 'Cuerpo del mensaje vacío';
$PHPMAILER_LANG['encoding'] = 'Codificación desconocida: ';
-$PHPMAILER_LANG['execute'] = 'No puedo ejecutar: ';
-$PHPMAILER_LANG['file_access'] = 'No puedo acceder al archivo: ';
-$PHPMAILER_LANG['file_open'] = 'Error de Archivo: No puede abrir el archivo: ';
+$PHPMAILER_LANG['execute'] = 'No se pudo ejecutar: ';
+$PHPMAILER_LANG['file_access'] = 'No se pudo acceder al archivo: ';
+$PHPMAILER_LANG['file_open'] = 'Error de Archivo: No se pudo abrir el archivo: ';
$PHPMAILER_LANG['from_failed'] = 'La(s) siguiente(s) direcciones de remitente fallaron: ';
-$PHPMAILER_LANG['instantiate'] = 'No pude crear una instancia de la función Mail.';
-//$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['instantiate'] = 'No se pudo crear una instancia de la función Mail.';
+$PHPMAILER_LANG['invalid_address'] = 'No se pudo enviar: dirección de email inválido: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no está soportado.';
-$PHPMAILER_LANG['provide_address'] = 'Debe proveer al menos una dirección de email como destinatario.';
-$PHPMAILER_LANG['recipients_failed'] = 'Error SMTP: Los siguientes destinatarios fallaron: ';
+$PHPMAILER_LANG['provide_address'] = 'Debe proveer al menos una dirección de email como destino.';
+$PHPMAILER_LANG['recipients_failed'] = 'Error SMTP: Los siguientes destinos fallaron: ';
$PHPMAILER_LANG['signing'] = 'Error al firmar: ';
-//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
-//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
-//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() se falló.';
+$PHPMAILER_LANG['smtp_error'] = 'Error del servidor SMTP: ';
+$PHPMAILER_LANG['variable_set'] = 'No se pudo ajustar o reajustar la variable: ';
diff --git a/test_script/contents.html b/test_script/contents.html
index 741d3d2d..89f90b12 100644
--- a/test_script/contents.html
+++ b/test_script/contents.html
@@ -1,14 +1,12 @@
-
-
-
- This is a test of PHPMailer v5.0.0 for PHP5/6.
-
-This particular example uses HTML, with a <div> tag and inline
-styles.
-
-Also note the use of the PHPMailer at the top with no specific code to handle
-including it in the body of the email.
-
-
-
+
+
+
+
+
+
+
This is a test of PHPMailer v5.0.0 for PHP5/6.
+
This particular example uses HTML, with a <div> tag and inline styles.
+
Also note the use of the PHPMailer at the top with no specific code to handle including it in the body of the email.
+
+
";
+ $CFG['smtp_debug'] = 1;
+ $CFG['smtp_server'] = 'mail.yourserver.com';
+ $CFG['smtp_port'] = '25';
+ $CFG['smtp_authenticate'] = 'true';
+ $CFG['smtp_username'] = 'name@yourserver.com';
+ $CFG['smtp_password'] = 'yourpassword';
+ $CFG['smtp_secure'] = 'None';
-if ( substr(phpversion(),0,1) < 5 ) { echo exit("ERROR: Wrong PHP version"); }
+ $from_name = ( isset($_POST['From_Name'])) ? $_POST['From_Name'] : '';
+ $from_email = ( isset($_POST['From_Email'])) ? $_POST['From_Email'] : '';
+ $to_name = ( isset($_POST['To_Name'])) ? $_POST['To_Name'] : '';
+ $to_email = ( isset($_POST['To_Email'])) ? $_POST['To_Email'] : '';
+ $cc_email = ( isset($_POST['cc_Email'])) ? $_POST['cc_Email'] : '';
+ $bcc_email = ( isset($_POST['bcc_Email'])) ? $_POST['bcc_Email'] : '';
+ $subject = ( isset($_POST['Subject'])) ? $_POST['Subject'] : '';
+ $message = ( isset($_POST['Message'])) ? $_POST['Message'] : '';
+ $test_type = ( isset($_POST['test_type'])) ? $_POST['test_type'] : '';
+ $smtp_debug = ( isset($_POST['smtp_debug'])) ? $_POST['smtp_debug'] : $CFG['smtp_debug'];
+ $smtp_server = ( isset($_POST['smtp_server'])) ? $_POST['smtp_server'] : $CFG['smtp_server'];
+ $smtp_port = ( isset($_POST['smtp_port'])) ? $_POST['smtp_port'] : $CFG['smtp_port'];
+ $smtp_secure = strtolower(( isset($_POST['smtp_secure'])) ? $_POST['smtp_secure'] : $CFG['smtp_secure']);
+ $smtp_authenticate = ( isset($_POST['smtp_authenticate'])) ? $_POST['smtp_authenticate'] : $CFG['smtp_authenticate'];
+ $authenticate_password = ( isset($_POST['authenticate_password'])) ? $_POST['authenticate_password'] : $CFG['smtp_password'];
+ $authenticate_username = ( isset($_POST['authenticate_username'])) ? $_POST['authenticate_username'] : $CFG['smtp_username'];
-$CFG['smtp_debug'] = 1;
-$CFG['smtp_server'] = 'mail.yourserver.com';
-$CFG['smtp_port'] = '25';
-$CFG['smtp_authenticate'] = 'true';
-$CFG['smtp_username'] = 'name@yourserver.com';
-$CFG['smtp_password'] = 'yourpassword';
-if ( $_POST['submit'] == "Submit" ) {
+ // storing all status output from the script to be shown to the user later
+ $results_messages = array();
+
+ // $example_code represents the "final code" that we're using, and will
+ // be shown to the user at the end.
+ $example_code = "\nrequire_once(\"../class.phpmailer.php\");";
+ $example_code .= "\nrequire_once(\"../extras/class.html2text.inc\");";
+ $example_code .= "\n\n\$results_messages = new array();";
class phpmailerAppException extends Exception {
public function errorMessage() {
- $errorMsg = '' . $this->getMessage() . " ";
+ $errorMsg = $this->getMessage();
return $errorMsg;
}
}
+
+ $example_code .= "\n\nclass phpmailerAppException extends Exception {";
+ $example_code .= "\n public function errorMessage() {";
+ $example_code .= "\n \$errorMsg = \$this->getMessage();";
+ $example_code .= "\n return \$errorMsg;";
+ $example_code .= "\n }";
+ $example_code .= "\n}";
- try {
- $to = $_POST['To_Email'];
- if(filter_var($to, FILTER_VALIDATE_EMAIL) === FALSE) {
- throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting! ");
+
+ if ( isset($_POST["submit"]) && $_POST['submit'] == "Submit" ) {
+
+ try {
+ $to = $_POST['To_Email'];
+ if(filter_var($to, FILTER_VALIDATE_EMAIL) === FALSE) {
+ throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting! ");
+ }
+ }
+ catch (phpmailerAppException $e) {
+ $results_messages[] = $e->errorMessage();
}
- } catch (phpmailerAppException $e) {
- echo $e->errorMessage();
- return false;
- }
- require_once("../class.phpmailer.php");
+ $example_code .= "\n\ntry {";
+ $example_code .= "\n \$to = \$_POST[\"To_Email\"];";
+ $example_code .= "\n if(filter_var(\$to, FILTER_VALIDATE_EMAIL) === FALSE) {";
+ $example_code .= "\n throw new phpmailerAppException(\"Email address \" . \$to . \" is invalid -- aborting! \");";
+ $example_code .= "\n }";
+ $example_code .= "\n}";
+ $example_code .= "\ncatch (phpmailerAppException \$e) {";
+ $example_code .= "\n \$results_messages[] = \$e->errorMessage()";
+ $example_code .= "\n}";
- $mail = new PHPMailer();
+ $mail = new PHPMailer();
+ $example_code .= "\n\n\$mail = new PHPMailer();";
- if ( $_POST['Message'] == '' ) {
- $body = file_get_contents('contents.html');
- } else {
- $body = $_POST['Message'];
- }
+ if ( $_POST['test_type'] == "smtp" ) {
+ $mail->IsSMTP(); // telling the class to use SMTP
+ $mail->SMTPDebug = $_POST['smtp_debug'];
+ $mail->Host = $_POST['smtp_server']; // SMTP server
+ $mail->Port = $_POST['smtp_port']; // set the SMTP port
+ if ($_POST['smtp_secure']) {
+ $mail->SMTPSecure = strtolower($_POST['smtp_secure']);
+ }
+ $mail->SMTPAuth = $_POST['smtp_authenticate']; // enable SMTP authentication
+ if ($_POST['smtp_authenticate']) {
+ $mail->Username = $_POST['authenticate_username']; // SMTP account username
+ $mail->Password = $_POST['authenticate_password']; // SMTP account password
+ }
- if ( $_POST['test_type'] == "smtp" ) {
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->SMTPDebug = $_POST['smtp_debug'];
- $mail->SMTPAuth = $_POST['smtp_authenticate']; // enable SMTP authentication
- $mail->Port = $_POST['smtp_port']; // set the SMTP port
- $mail->Host = $_POST['smtp_server']; // SMTP server
- $mail->Username = $_POST['authenticate_username']; // SMTP account username
- $mail->Password = $_POST['authenticate_password']; // SMTP account password
- } elseif ( $_POST['test_type'] == "mail" ) {
- $mail->IsMail(); // telling the class to use PHP's Mail()
- } elseif ( $_POST['test_type'] == "sendmail" ) {
- $mail->IsSendmail(); // telling the class to use Sendmail
- } elseif ( $_POST['test_type'] == "qmail" ) {
- $mail->IsQmail(); // telling the class to use Qmail
- }
+ $example_code .= "\n\$mail->IsSMTP();";
+ $example_code .= "\n\$mail->SMTPDebug = \"".$_POST['smtp_debug']."\";";
+ $example_code .= "\n\$mail->Host = \"".$_POST['smtp_server']."\";";
+ $example_code .= "\n\$mail->Port = \"".$_POST['smtp_port']."\";";
+ $example_code .= "\n\$mail->SMTPSecure = \"".strtolower($_POST['smtp_secure'])."\";";
+ $example_code .= "\n\$mail->SMTPAuth = \"".$_POST['smtp_authenticate']."\";";
+ if ($_POST['smtp_authenticate']) {
+ $example_code .= "\n\$mail->Username = \"".$_POST['authenticate_username']."\";";
+ $example_code .= "\n\$mail->Password = \"".$_POST['authenticate_password']."\";";
+ }
- if ( $_POST['From_Name'] != '' ) {
- $mail->AddReplyTo($_POST['From_Email'],$_POST['From_Name']);
- $mail->From = $_POST['From_Email'];
- $mail->FromName = $_POST['From_Name'];
- } else {
- $mail->AddReplyTo($_POST['From_Email']);
- $mail->From = $_POST['From_Email'];
- $mail->FromName = $_POST['From_Email'];
- }
-
- if ( $_POST['To_Name'] != '' ) {
- $mail->AddAddress($to,$_POST['To_Name']);
- } else {
- $mail->AddAddress($to);
- }
-
- if ( $_POST['bcc_Email'] != '' ) {
- $indiBCC = explode(" ", $_POST['bcc_Email']);
- foreach ($indiBCC as $key => $value) {
- $mail->AddBCC($value);
+ }
+ elseif ( $_POST['test_type'] == "mail" ) {
+ $mail->IsMail(); // telling the class to use PHP's Mail()
+ $example_code .= "\n\$mail->IsMail();";
+ }
+ elseif ( $_POST['test_type'] == "sendmail" ) {
+ $mail->IsSendmail(); // telling the class to use Sendmail
+ $example_code .= "\n\$mail->IsSendmail();";
+ }
+ elseif ( $_POST['test_type'] == "qmail" ) {
+ $mail->IsQmail(); // telling the class to use Qmail
+ $example_code .= "\n\$mail->IsQmail();";
}
- }
- if ( $_POST['cc_Email'] != '' ) {
- $indiCC = explode(" ", $_POST['cc_Email']);
- foreach ($indiCC as $key => $value) {
- $mail->AddCC($value);
+ if ( $_POST['From_Name'] != '' ) {
+ $mail->AddReplyTo($_POST['From_Email'],$_POST['From_Name']);
+ $mail->From = $_POST['From_Email'];
+ $mail->FromName = $_POST['From_Name'];
+
+ $example_code .= "\n\$mail->AddReplyTo(\"".$_POST['From_Email']."\",\"".$_POST['From_Name']."\");";
+ $example_code .= "\n\$mail->From = \"".$_POST['From_Email']."\");";
+ $example_code .= "\n\$mail->FromName = \"".$_POST['From_Name']."\");";
+ }
+ else {
+ $mail->AddReplyTo($_POST['From_Email']);
+ $mail->From = $_POST['From_Email'];
+ $mail->FromName = $_POST['From_Email'];
+
+ $example_code .= "\n\$mail->AddReplyTo(\"".$_POST['From_Email']."\");";
+ $example_code .= "\n\$mail->From = \"".$_POST['From_Email']."\";";
+ $example_code .= "\n\$mail->FromName = \"".$_POST['From_Email']."\";";
}
- }
- $mail->Subject = $_POST['Subject'] . ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')';
-
- // below can be found at http://www.chuggnutt.com/html2text
- // bundled in ./extras/
- require_once('../class.html2text.inc');
- $h2t =& new html2text($body);
- $mail->AltBody = $h2t->get_text();
- //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
- $mail->WordWrap = 80; // set word wrap
-
- $mail->MsgHTML($body);
-
- // $mail->IsHTML(true); // send as HTML
-
- $mail->AddAttachment("images/aikido.gif", "aikido.gif"); // optional name
- $mail->AddAttachment("images/phpmailer.gif", "phpmailer.gif"); // optional name
-
- try {
- if ( !$mail->Send() ) {
- $error = "Unable to send to: " . $to . " ";
- throw new phpmailerAppException($error);
- } else {
- echo 'Message has been sent using ' . strtoupper($_POST['test_type']) . "
\ No newline at end of file
diff --git a/test_script/index.php b/test_script/index.php
index 3bb4f247..55d36bc8 100644
--- a/test_script/index.php
+++ b/test_script/index.php
@@ -1,427 +1,558 @@
-
-
-