TLS send mail in scriptcase

[telenet_smtp]=‘smtp.telenet.be’;
[user]=‘site@telenet.be’;
[user_pw]=‘password’;
[from]=‘sender@telenet.be’;
[to]=‘receiver@telenet.be’;
[subject]=‘mijn uitnodiging’;
[message]=“http file or string”);
[glo_copies]=’’;
[attached]=’’;
sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, [glo_copies], ‘CCC’, ‘25’, ‘N’, [attached]);

When i send to port 25 and no encryption it works fine, but there are webproviders who drop the mail and so not everyone receive my mails.

So i need to send it protected as TLS on port 587 but then i receive always errors

[SIZE=14px]Fatal error: Uncaught Swift_TransportException: Unable to connect with TLS encryption in C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Transport\EsmtpTransport.php:315 Stack trace: #0 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Transport\AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand() #1 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #2 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\crelanfriendsn\mailsend01\index.php(1535): Swift_Mailer->send(Object(Swift_Message), Array) #3 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\crelanfriendsn\mailsend01\index.php(2079): mailsend01_apl->controle() #4 {main} thrown in C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Transport\EsmtpTransport.php on line 315[/SIZE]

Some one could help?
Thanks in advance,

William.

could you please sare your code with me?.. so I can help you?.

Regards

Shure kafecadm thanks in advance, i send the source here :

//[telenet_smtp]=‘195.130.132.11’;
[telenet_smtp]=smtp.telenet.be’;
//[user]=‘crelanfriends@telenet.be’;
[user]=‘william.verhoeven@telenet.be’;
[user_pw]=‘PASSWORD’;
//[from]=‘banketnl@telenet.be’;
[from]=‘william.verhoeven@telenet.be’;
[to]=‘mjr.martens@skynet.be’;
[subject]=‘mijn testuitnodiging naar Marie-Jeanne Martens’;
[message]=file_get_contents(“http://www.broersplus.x10.mx/htm/mj01.htm”);
[glo_copies]=’’;
[attached]=’’;
//[SSLTLS]=‘openssl s_client -starttls smtp -crlf -connect 195.130.132.11:25’
sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, [glo_copies], ‘CCC’, ‘25’, ‘N’, [attached]);
//sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, [glo_copies], ‘CCC’, ‘465’, ‘S’, [attached]);
//sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, [glo_copies], ‘BCC’, ‘587’, ‘T’);
//sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, [glo_copies], ‘CCC’, ‘587’, ‘T’, [attached],[SSLTLS]);

ok i think I’ve seen your problem, try this:

sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, ‘’, ‘’, ‘587’, ‘T’, [attached]);

So i executed the source here under:

[telenet_smtp]=‘smtp.telenet.be’;
[user]=‘USERID’;
[user_pw]=‘PASSWORD’;
[from]=‘USERID’;
[to]=‘OTHER USERID’;
[subject]=‘mijn testuitnodiging naar iemand’;
[message]=file_get_contents(“http://www.broersplus.x10.mx/htm/mj01.htm”);
[attached]=’’;
sc_mail_send([telenet_smtp], [user], [user_pw], [from], [to], [subject], [message], ‘H’, ‘’, ‘’, ‘587’, ‘T’, [attached]);

I receive error:

Fatal error: Uncaught Swift_TransportException: Unable to connect with TLS encryption in C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Transport\EsmtpTransport.php:315 Stack trace: #0 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Transport\AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand() #1 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #2 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\crelanfriends\mailsend\index.php(1512): Swift_Mailer->send(Object(Swift_Message), Array) #3 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\crelanfriends\mailsend\index.php(2031): mailsend_apl->controle() #4 {main} thrown in C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod hird\swift\classes\Swift\Transport\EsmtpTransport.php on line 315

Thanks for your help, other idea’s?

Use PHPmailer https://github.com/Synchro/PHPMailer

  1. add dowloaded content via external library into SC

  2. use code eg with a button in a form

sc_include_library(“prj”, “PHPMailer”, “PHPMailerAutoload.php”); // replaces require ‘PHPMailerAutoload.php’;

$mail = new PHPMailer;

//$mail->SMTPDebug = 3; // Enable verbose debug output

$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ‘smtp.telenet.be’; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ‘telenet_Login’; // SMTP username
$mail->Password = ‘telenet_PW’; // SMTP password
$mail->SMTPSecure = ‘tls’; // Enable TLS encryption, ssl also accepted
$mail->Port = 587; // TCP port to connect to

$mail->setFrom(‘email@telenet.be’,‘Mike’);
$mail->addAddress(‘email@telenet.be’,‘mrX’); // Add a recipient
//$mail->addAddress(‘ellen@example.com’); // Name is optional
//$mail->addReplyTo(‘info@example.com’, ‘Information’);
//$mail->addCC(‘cc@example.com’);
//$mail->addBCC(‘bcc@example.com’);

//$mail->addAttachment(’/var/tmp/file.tar.gz’); // Add attachments
//$mail->addAttachment(’/tmp/image.jpg’, ‘new.jpg’); // Optional name
$mail->isHTML(true); // Set email format to HTML

$mail->Subject = ‘Here is the subject’;
$mail->Body = ‘This is the HTML message body <b>in bold!</b>’;
$mail->AltBody = ‘This is the body in plain text for non-HTML mail clients’;
$mail->SMTPOptions = array( //OPTIEREGEL MOET ER STAAN ZONIET FOUTMELDING
‘ssl’ => array(
‘verify_peer’ => false,
‘verify_peer_name’ => false,
‘allow_self_signed’ => true
));

if(!$mail->send()) {
echo ‘Message could not be sent.’;
echo 'Mailer Error: ’ . $mail->ErrorInfo;
} else {
echo ‘Message has been sent’;
}

Works like a sharm!!!

Werkt perfect!!!

Use PHPmailer

  1. download at https://github.com/Synchro/PHPMailer and add to library
  2. enable code eg with a button on a form

sc_include_library(“prj”, “PHPMailer”, “PHPMailerAutoload.php”); //require ‘PHPMailerAutoload.php’;

$mail = new PHPMailer;

//$mail->SMTPDebug = 3; // Enable verbose debug output

$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ‘smtp.telenet.be’; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ‘loginTelenet’; // SMTP username
$mail->Password = ‘PWtelenet’; // SMTP password
$mail->SMTPSecure = ‘tls’; // Enable TLS encryption, ssl also accepted
$mail->Port = 587; // TCP port to connect to

$mail->setFrom(‘mike.vanlierde@telenet.be’,‘Mike’);
$mail->addAddress(‘mvl123@telenet.be’); // Add a recipient
//$mail->addAddress(‘ellen@example.com’); // Name is optional
//$mail->addReplyTo(‘info@example.com’, ‘Information’);
//$mail->addCC(‘cc@example.com’);
//$mail->addBCC(‘bcc@example.com’);

//$mail->addAttachment(’/var/tmp/file.tar.gz’); // Add attachments
//$mail->addAttachment(’/tmp/image.jpg’, ‘new.jpg’); // Optional name
$mail->isHTML(true); // Set email format to HTML

$mail->Subject = ‘Here is the subject’;
$mail->Body = ‘This is the HTML message body <b>in bold!</b>’;
$mail->AltBody = ‘This is the body in plain text for non-HTML mail clients’;
$mail->SMTPOptions = array( //REGEL MOET ER STAAN zoniet foutmelding
‘ssl’ => array(
‘verify_peer’ => false,
‘verify_peer_name’ => false,
‘allow_self_signed’ => true
));

if(!$mail->send()) {
echo ‘Message could not be sent.’;
echo 'Mailer Error: ’ . $mail->ErrorInfo;
} else {
echo ‘Message has been sent’;
}

Works like a charm

Werkt perfect!!

Have you tried sending a mail with another program just to test your settings?.. commonly the port used for this is the 465 not the 587.

Regards

Yes i send with the same settings with “atomic mail sender” , there are persons who don’treceive my mals but that is with settings their side. I send 106 mails and there are 97 who are repleiing.

That has happened to me a couple of times… well if the sc macro doesn?t work i recommend to use something like this


require_once('scripts/phpmailer/class.phpmailer.php');  
$mail = new PHPMailer();

$mail->IsSMTP();                       // telling the class to use SMTP
 
  $mail->SMTPDebug = 0;                  
  // 0 = no output, 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 

$mail->Username = "info@example.com";  // Gmail username
$mail->Password = "yourpassword";      // Gmail password

$mail->CharSet = 'windows-1250';
$mail->SetFrom ('info@example.com', 'Example.com Information');
$mail->AddBCC ( 'sales@example.com', 'Example.com Sales Dep.'); 
$mail->Subject = $subject;
$mail->ContentType = 'text/plain'; 
$mail->IsHTML(false);
  
$mail->Body = $body_of_your_email; 
  // you may also use $mail->Body = file_get_contents('your_mail_template.html');
   
  $mail->AddAddress ('your.recipient@domain.com', 'Recipients Name');     
  // you may also use this format $mail->AddAddress ($recipient);

if(!$mail->Send()) 
{
        $error_message = "Mailer Error: " . $mail->ErrorInfo;
} else 
  {
        $error_message = "Successfully sent!";
}
   
 
```php
1 Like

That has happened to me before… well if scriptcase macros won’t work i recommend using php. something like this.


require_once('scripts/phpmailer/class.phpmailer.php');  
$mail = new PHPMailer();

$mail->IsSMTP();                       // telling the class to use SMTP
 
  $mail->SMTPDebug = 0;                  
  // 0 = no output, 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 

$mail->Username = "info@example.com";  // Gmail username
$mail->Password = "yourpassword";      // Gmail password

$mail->CharSet = 'windows-1250';
$mail->SetFrom ('info@example.com', 'Example.com Information');
$mail->AddBCC ( 'sales@example.com', 'Example.com Sales Dep.'); 
$mail->Subject = $subject;
$mail->ContentType = 'text/plain'; 
$mail->IsHTML(false);
  
$mail->Body = $body_of_your_email; 
  // you may also use $mail->Body = file_get_contents('your_mail_template.html');
   
  $mail->AddAddress ('your.recipient@domain.com', 'Recipients Name');     
  // you may also use this format $mail->AddAddress ($recipient);

if(!$mail->Send()) 
{
        $error_message = "Mailer Error: " . $mail->ErrorInfo;
} else 
  {
        $error_message = "Successfully sent!";
}
   
 


```php

Thanks “nonkelMike” it works great. But when SC makes a macro sc_mail_send we are obliged to work with phpmailer? Thats maybe also a question to Albert from aducom.

But mike again thank you very much.

I know there have been issues with TLS and scriptcase but afaik they where solved. Besides that, I think that if SC has a macro for that then you should stay with that macro and not add more third parties. But only if it works. In this case i would do the same and php mailer is a good package.

Thanks Prof Albert. Ther are good third party libraries who extend sc and make it again a lot better. Is it not done to make a list here from libraries sc developers use and why thy find it so super?

from nonkelmike above, the include is looking for “PHPMailerAutoload.php” but that is not in the github code. Where to find the autoload?

sc_include_library(“prj”, “PHPMailer”, “PHPMailerAutoload.php”); // replaces require ‘PHPMailerAutoload.php’;

This is still a problem in 9.10.0023 almost 10 years from the first reported problem (a different post).
The issue seems to be located in the Scriptcase provided Apache server as relevant apps work on the production server but not the development environment.
That sounds OK, but it isn’t!
To test anything using the macro on the Development environment, you have to make the the mailer insecure, which means your not fully testing. The only way then to properly test is to deploy to the prod server and test it there, which is REALLY bad practice.
I’ve tried the suggestions in a scriptcase post in the PHP.INI file, but they don’t work for me.

This is another one of the Scriptcase blind spots, where they think its OK for all of us users to waste days, tracking down problems that they should fix at source (think also wkhtmltopdf as well). In the end, its why we’ve stopped using SC for NEW projects, no longer pay for upgrades and only use it to maintain existing code. Sad really, because I love the concept and most of the execution, but can’t afford these kinds of overhead, when there are other solutions out there.