Announcement

Collapse
No announcement yet.

Sending mail with attachment on the form

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    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

    Comment


    • #3
      Originally posted by rr View Post
      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
      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?

      Comment


      • #4
        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/...o-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);

        Comment

        Working...
        X