Announcement

Collapse
No announcement yet.

Sending EMAILS with SCRIPTCASE

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending EMAILS with SCRIPTCASE

    To send an email with Scriptcase we will use sc_mail_send Macro.

    First, I've created a Control application with an unique field where we will type the message.

    In onValidate Event I am using this code:


    $smtp = "smtp.mail.yahoo.com.br"; //smtp address
    $usr = "arteiro.netmake"; //User name
    $pw = "netmake2009"; //Password
    $out = "arteiro.netmake@yahoo.com.br"; //message from
    $in = "youremail@xxx.com"; //message to
    $sbj = "Sending email using Scriptcase"; //Subject
    $msg = {texto}; //body message - {texto} is a field of the form

    sc_mail_send ($smtp, $usr, $pw, $out, $in, $sbj, $msg, 'H', '', '', '587');

  • #2
    Re: Sending EMAILS with SCRIPTCASE

    Tutorials How to send email using Scriptcase.

    http://www.scriptcase.net/phpgenerat...ming/mcr06.php

    Sending email with attachments

    http://www.scriptcase.net/phpgenerat...ming/mcr13.php

    Comment


    • #3
      Re: Sending EMAILS with SCRIPTCASE

      Hi,
      While this works fine on my desktop development (Linux/Apache) box, it falls over on my virtual hosting service.

      I have reverted to the standard PHP mail() function

      sc_error_exit() ;
      $msg = {fullname}." requests more information to be emailed to ".{email}.".Reason: ".{message};
      $sbj = "Info Request from Website- Index ".[parm1].": ".[parm2];
      $to = "admin@ourserver.gov.au";
      $headers = "From: noreply@ourserver.gov.au<br /> Cc:w...@ourserver.net";

      if (mail($to, $sbj, $msg,$headers)) {
      sc_alert("Message successfully sent!");
      } else {
      sc_alert("Message delivery failed...");
      }
      The GuiGuy
      ... from Down Under

      Comment


      • #4
        Re: Sending EMAILS with SCRIPTCASE

        You may also want to have a look at PHPMailer:
        http://phpmailer.worxware.com/

        I simply copied the download to a directory under my app and called it with include(..) as shown in the examples.

        They have plenty of examples and I have tested the SMTP example as working fine a SC5 Control app.
        http://phpmailer.worxware.com/index.php?pg=examplebsmtp

        Other examples.
        http://phpmailer.worxware.com/index.php?pg=examples

        Regards,
        Scott.

        Comment


        • #5
          Re: Sending EMAILS with SCRIPTCASE

          [quote author=ScottMartin link=topic=1371.msg4431#msg4431 date=1270559770]
          You may also want to have a look at PHPMailer:
          http://phpmailer.worxware.com/
          <snip>
          [/quote]

          Thanks, Scott.

          It remains that it would be neat if the inbuilt macro was working, though.

          ON the upside, writing a PHP code snippet isn't a big deal.

          Cheers

          The GuiGuy
          ... from Down Under

          Comment


          • #6
            Re: Sending EMAILS with SCRIPTCASE

            Hi all!
            i want to know how can i send an email to a several email address? is this possible?
            Thanks in advance!

            Comment


            • #7
              Re: Sending EMAILS with SCRIPTCASE

              [quote author=hikiboy link=topic=1371.msg6796#msg6796 date=1291923541]
              Hi all!
              i want to know how can i send an email to a several email address? is this possible?
              Thanks in advance!
              [/quote]

              Yes, you can use a "foreach", "for", "while" or another loop command to get emails from an array and send the emails.

              Comment


              • #8
                Re: Sending EMAILS with SCRIPTCASE

                Hi Vitor,

                My Gmail account requires TLS encryption how can I set this up so that I can send emails using the sc_mail macro.
                Many thanks.

                George

                Comment


                • #9
                  Re: Sending EMAILS with SCRIPTCASE

                  Hi,
                  I have set up sc_mail using Vitors settings and it works. However when I set up my gmail account I get the following message:

                  Uncaught Error of type [Swift_ConnectionException] with message [Authentication failed using username 'georgeloseby' and password '*********']

                  I am using the same username and password in my Outlook settings which is working.
                  Please can you assist.
                  Many thanks
                  Georghe

                  Comment


                  • #10
                    Re: Sending EMAILS with SCRIPTCASE

                    [quote author=gloseby link=topic=1371.msg10009#msg10009 date=1303398096]
                    Hi,
                    I have set up sc_mail using Vitors settings and it works. However when I set up my gmail account I get the following message:

                    Uncaught Error of type [Swift_ConnectionException] with message [Authentication failed using username 'georgeloseby' and password '*********']

                    I am using the same username and password in my Outlook settings which is working.
                    Please can you assist.
                    Many thanks
                    Georghe

                    [/quote]

                    I figure this out.. I hope someone still needs help on this.
                    All i had to do is change the port to 465 and add 'S' right after the port to make it SSL (Secure)..
                    Works like a charm. Look at example below..

                    $smtp = "smtp.gmail.com"; //smtp address
                    $usr = "enter@yourgmailaddress.com"; //User name
                    $pw = "enteryourpassword"; //Password
                    $out = "from@emailaddress.com"; //message from
                    $in = to@emailaddress.com; //message to
                    $sbj = "Sending email using Scriptcase"; //Subject
                    $msg = {texto}; //body message - {texto} is a field of the form

                    sc_mail_send ($smtp, $usr, $pw, $out, $in, $sbj, $msg, 'T', '', '', '465','S');

                    Comment


                    • #11
                      i have a problem with email header, need help

                      I have a problem with email header, in this sc_mail_send there are no header email, so it make my mail server can not fill the "from" field ... i send the picture latter cause i'm still in my office now, so i cant uploading every data. how can u give the solution for the header of the email using sc_mail_send??






                      Best regard

                      Yogie
                      thx

                      Comment


                      • #12
                        Thank you all for this post, this is exactly what i am looking for..

                        Comment


                        • #13
                          Thanks very much for posting this! I'm sure it will be really helpful
                          220-902 Exam Questions

                          Comment


                          • #14
                            Here is example of another method: PHP Script for Sending Email using Gmail SMTP

                            For sending email using SMTP we need not have entire PHPMailer library. It is sufficient to have only class.phpmailer.php and class.smtp.php of this library.

                            We should set subject, content and header information. When we send email using Gmail SMTP make sure to set SMTPAuth as TRUE and SMTPSecure as tls/ssl. Use your Gmail Username and Password to send email.

                            <?php require('phpmailer/class.phpmailer.php');
                            $mail =newPHPMailer();
                            $mail->IsSMTP();
                            $mail->SMTPDebug=0;
                            $mail->SMTPAuth= TRUE;
                            $mail->SMTPSecure="tls";
                            $mail->Port=587;
                            $mail->Username="your gmail username";
                            $mail->Password="your gmail password";
                            $mail->Host="smtp.gmail.com";
                            $mail->Mailer="smtp";
                            $mail->SetFrom("Your from email","from name");
                            $mail->AddReplyTo("from email","PHPPot");
                            $mail->AddAddress("recipient email");
                            $mail->Subject="Test email using PHP mailer";
                            $mail->WordWrap=80;
                            $content ="<b>This is a test email using PHP mailer class.</b>";
                            $mail->MsgHTML($content);
                            $mail->IsHTML(true);
                            if(!$mail->Send()) echo "Problem sending email.";
                            else echo "email sent.";?>

                            For setting FromEmail and FromName, we can either use SetFrom()function or use PHPMailer properties PHPMailer::From and PHPMailer::FromName. For example,

                            $mail->From="from email address";
                            $mail->FromName="from name"; AddReplyTo(), AddAddress() functions will accept array of email addresses, and name is optional.

                            If we have HTML content as mail body, we need to set content body text/html by using,

                            $mail->IsHTML(true);

                            After setting all properties and mailer information with PHPMailer object, PHPMailer::send() function returns TRUE on successful mail transfer and FALSE on failure.
                            Last edited by Dr Tim; Yesterday, 01:34 PM.

                            Comment

                            Working...
                            X