Sending mail with attachment on the form

Hello,
I can’t send a mail on form with AfterInstert section. It sends well on SC platform but when I deploy my application, it don’t send mail. I tried without attachment and it worked well, how can I send mail with attachment on the live platform?

My codes:AfterInsert:

// Email parameters
if ( {attachment} !=null ) {
$file=$this->Ini->path_doc.’/’.{attachment};
$fileName = " | ‘".{attachment}."’ files.";
}
else{
$file=NULL;
$fileName=NULL;
}

$mail_smtp_server = ‘ssl://smtp.gmail.com’; // SMTP server name or IP address
$mail_smtp_user = ‘b@a.com’; // SMTP user name
$mail_smtp_pass = ‘1234’; // SMTP password
$mail_from = ‘b@a.com’; // From email
$mail_to = ‘a@b.com’; // To email
$mail_subject = 'New Report Request: '.{report}; // Message subject
$mail_message = 'Report Name: ‘.{report}.’ .$fileName; // Message body
$mail_format = ‘H’; // Message format: (T)ext or (H)tml
$mail_attachments = $file;

// Send email
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_format,
‘’,
‘’,
‘465’,
‘’,
$mail_attachments);

This codes only works locally, SC platform. Does not work with attachment on the live.

Can you be more precise as to what isng working?
Anyway I i think that this: $mail_smtp_server = ‘ssl://smtp.gmail.com’; is wrong. ssl:// is not correct. I am amazed that you would be able to get that working. If you indeed did get that exactly working then you should check if you installed openssl on your live machine.

Check here for details:
https://support.google.com/a/answer/176600?hl=en

[QUOTE=rr;32930]Can you be more precise as to what isng working?
Anyway I i think that this: $mail_smtp_server = ‘ssl://smtp.gmail.com’; is wrong. ssl:// is not correct. I am amazed that you would be able to get that working. If you indeed did get that exactly working then you should check if you installed openssl on your live machine.

Check here for details:
https://support.google.com/a/answer/176600?hl=en[/QUOTE]

I installed openssl on my live machine. It works well on my local development machine. My live platform on Amazon Web Services. I will check more about it but could it be attachment folder?

I would first test a normal mail without any attachment, preferably a mail in the simplest form. If that works then you know that your settings to send mail are working.
Then and only then I would use the more complicated mails (multiple recipients, attachments and so forth).
But ssl://smtp.gmail.com is not an smtp server address. But smtp.gmail.com is. If you want to use ssl you have to connect to the smtp.gmail.com ssl port
Please check here: http://www.scriptcase.net/knowledge/index.php?/Knowledgebase/Article/View/357/46/example-of-macro-sc_mail_send
I would also set the connection type to ‘S’, since it is ssl. So $mail_smtp_server=‘smtp.gmail.com’; $mail_security=‘S’; (see example 2 from above);

For record and those who have been having isssues with sending attachments my code below
NOTE: I HAD THE $mail_attachment in the middle of the param list of send mail and I get FATAL Errors. Moving it to the end resolved the problem

$target = “”; //./";
$filePath = $target . ‘entrycode-’ .{er_rowID} . ‘.png’;

$completePath = “D:\QRCODE\Test_QRCode.png”; //’/path/to/your/file.pdf’;
//$completePath = “Test_QRCode.png”; //’/path/to/your/file.pdf’;

$mail_smtp_server = ‘smtp.hostinger.com’; // SMTP server name or IP address
$mail_smtp_user = ‘user@gmail.com’; // SMTP user name
$mail_smtp_pass = ‘password’; // SMTP password
$mail_from = ‘iFROM@GMAIL>COM’; // From email
$mail_to = ‘TO@gmail.com’; {er_ev_email_address}; // ‘sriraminfotec@gmail.com’; // To email
$mail_subject = ‘Test message2’; // Message subject
$mail_message = ‘This is a test message. 2 ’ .{uniqueqrcode}; // Message body
//$mail_attachment = $completePath; // $completePath; MAIL ATTACHMENT SETTING AT THIS POINT GIVE FATAL ERROR
//$mail_attachment = $this->Ini->path_doc.’/’.$completePath; // $thius->Ini->path_doc gives C:/Program Files/NetMake/v9 php81/wwwroot/scriptcase/file/doc
$mail_format = ‘H’; // Message format: (T)ext or (H)tml
$mail_copies = ‘’; // List of the emails that will recieve the message
$mail_tp_copies = ‘’; // Type copies: BCC (Hiden copies) or CCC (Regular copies)
$mail_port = ‘465’; //‘465’; // Server port
$mail_tp_connection = ‘S’;
//$mail_attachment = $this->Ini->path_doc.’/’.$completePath; // $thius->Ini->path_doc gives C:/Program Files/NetMake/v9-php81/wwwroot/scriptcase/file/doc// Connection security (S) or (N)
$mail_attachment = $completePath; // $completePath;
echo ($mail_attachment);
// Send email";
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
//$mail_attachment, // TO BE MORE PRECISE MAIL ATTACHMENT AT THIS POINT GIVES FATAL ERROR
$mail_format,
$mail_copies,
$mail_tp_copies,
$mail_port,
$mail_tp_connection,
$mail_attachment); // MAIL ATTACHMENT IN LAST LINE IS OK AND WORKING FILE