Announcement

Collapse
No announcement yet.

php mail function

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

  • php mail function

    Hello Everyone at the VH forum,

    When I use this mail function:
    PHP Code:
    $my_email 'LUSOPIPE <lusopipe@crmpt.com>';
    $extra "From: $meu_email\r\n";
    $recipient  "$email_tosendto";
    include(
    "include/subject_and_message.php");
    mail ($recipient$subject$message$extra); 
    to send automatic emails on my php program, people are receiving emails saying:

    *****@voda26.voda26.com in name of LUSOPIPE [lusopipe@crmpt.com]

    ***** is my control panel username.
    www.crmpt.com is my domain name (one of).

    How can I avoid the:
    *****@voda26.voda26.com in name of....

    Thanks in advance,
    pipesportugal
    Last edited by Karen Mac; 10-17-2008, 06:16 AM. Reason: posted control panel user name

  • #2
    Re: php mail function

    Only way: use PHP mailer that sends mails directly through Sendmail. Or any other mailer that performs SMTP authentication (Zend Mailer, Swift Mailer)
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment


    • #3
      Re: php mail function

      I have my scripts rewrite the From to me@mydomain.com. I believe it is possible. I do see a typo in the code though

      $my_email = 'LUSOPIPE <lusopipe@crmpt.com>';
      $extra = "From: $meu_email\r\n"
      ;
      --- should be ----
      $extra = "From: $my_email\r\n";
      $recipient = "$email_tosendto";
      include(
      "include/subject_and_message.php"
      );
      mail ($recipient, $subject, $message, $extra);

      Comment


      • #4
        Re: php mail function

        Mails generated by php scripts will have as "From" header whatever email address you provide, BUT in the mail properties it will ALWAYS be visible the server from which the mail comes from.

        Instead, sending through PHP Mailer or ZEND Mailer or Swift Mailer, with SMTP authentication, will result in the mail apearing as coming from your domain (instead of voda??.voda??.com)
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment


        • #5
          Re: php mail function

          Hello,

          Regarding the typing mistake, in my program I had it fixed.

          It's just that I translated my variable names to english, in order to who ever would read the thread to be able understand me. That one escaped me.

          Regarding the navaldesign's php mailer suggestion, I have been looking at php.net for this class and it seems a little bit more complicated than what I can handle, but I will try it though.

          Thanks,
          pipesportugal

          Comment


          • #6
            Re: php mail function

            PHP Mailer is not that complicated once you read the instructions.
            The new ABVFP version uses PHP Mailer to send mails and i asure you it only takes an hr or so to get used to it.
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment


            • #7
              Re: php mail function

              Hi naval,

              I read at the swift mailer website the following:

              "The only other popular alternative was PHPMailer which is no longer in active development, limited in support, lacking in modern features such as TLS and difficult to interface with."

              A lot based on these words I am now making tests ang going into swift direction. If I am not sucessfull with it, I'll change my course to PHPmailer then.

              I am geting a lot of parse errors while implementing this swift mailer class.

              $smtp = new Swift_Connection_SMTP("smtp.host.tld", 25);
              $smtp->setUsername("------");
              $smtp->setpassword("------");
              $swift = new Swift($smtp);

              What should I place instead of the smtp.host.tld ??
              a) mail.crmpt.com (the sender is something@crmpt.com)
              or
              b) voda26.voda26.com ?

              Thanks in advance for the help,
              pipesportugal

              Comment


              • #8
                Re: php mail function

                Hi, I was veing a little silly,

                Why asking and not testing instead ?

                Well, the results were:
                neither choices have worked !

                Any ideas ?

                pipesportugal

                Comment


                • #9
                  Re: php mail function

                  Originally posted by pipesportugal View Post
                  Hi naval,

                  I read at the swift mailer website the following:

                  "The only other popular alternative was PHPMailer which is no longer in active development, limited in support, lacking in modern features such as TLS and difficult to interface with."
                  Not true, phpmailer is in avtive development, the last release was November 20 2008. And it has a lot more features than what you might need unless you want to create a true, full scale, mail management script,

                  I use phpmailer, find it more immediate.

                  I am geting a lot of parse errors while implementing this swift mailer class.

                  $smtp = new Swift_Connection_SMTP("smtp.host.tld", 25);
                  $smtp->setUsername("------");
                  $smtp->setpassword("------");
                  $swift = new Swift($smtp);

                  What should I place instead of the smtp.host.tld ??
                  a) mail.crmpt.com (the sender is something@crmpt.com)
                  or
                  b) voda26.voda26.com ?
                  IF it works like phpmailer, it should be:


                  $smtp = new Swift_Connection_SMTP("localhost", 25);
                  $smtp->setUsername("youremail address used for sending smtp mail");
                  $smtp->setpassword("the password used for the specific email address");
                  $swift = new Swift($smtp);

                  I usually have these details in a separate config.file, so it becomes:

                  $smtp = new Swift_Connection_SMTP($smtp_host, 25);
                  $smtp->setUsername($smtp_mail_address);
                  $smtp->setpassword($smtp_password);
                  $swift = new Swift($smtp);
                  Navaldesign
                  Logger Lite: Low Cost, Customizable, multifeatured Login script
                  Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                  DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                  Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                  Comment


                  • #10
                    Re: php mail function

                    Hi naval thanks for replying,

                    It's working perfect now with the PHPmailer, except for the fact that all the returns on the text are not showing on the other side (at least at Microsoft Outlook).

                    It seems like the PHPmailer class has "eaten" the "\n" that I've put at the $message variable.

                    This is the code:
                    PHP Code:
                    require("phpmailer/class.phpmailer.php");  
                    #   
                    $mail = new PHPMailer();  
                    #   
                    $mail->IsSMTP();  // telling the class to use SMTP  
                    $mail->Host     "localhost"// SMTP server  
                    #   
                    include("include/email_body.php");
                    #
                    $mail->SMTPAuth true;     // turn on SMTP authentication
                    $mail->Username "lusopipe+crmpt.com";  // SMTP username
                    $mail->Password "------"// SMTP password
                    #
                    $meu_email2 'lusopipe@crmpt.com';
                    $mail->From     $meu_email2;  
                    $mail->FromName "my".$companyname;
                    #
                    $mail->AddAddress("$email_a_enviar");  
                    $mail->AddAddress("$p_emladm_parametro");                  // name is optional
                    #   
                    $mail->WordWrap 50;                                 // set word wrap to 50 characters
                    //$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 (i also tried the false word but still nothing...
                    $mail->Subject $subject;
                    $mail->Body    $message;
                    $mail->AltBody $message;
                    #   
                    if(!$mail->Send()) {  
                        echo(
                    "<script>window.alert('EMAIL NOT SEND ...ERROR: ".$mail->ErrorInfo."!')</script>"); 
                     } 
                    Also the include email_body:

                    PHP Code:
                    $subject "Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla ";
                     
                    $message  "AUTOMATIC EMAIL:\n";
                    $message .= "\nComercial: $scr_nome_vendedor,\n";
                    $message .= "\nFez a sua entrada N. ";
                    $message .= $visitas_totais;
                    $message .= " em MyLusopipe, a entidade com os seguintes dados:\n";
                    $message .= "\nNome da Entidade: $scr_nome_entidade";
                    $message .= "\nPessoa de Contacto: $scr_con0_entidade";
                    $message .= "\nTelemovel Contacto: $scr_tlmv0_entidade\n";
                    $message .= "\n$minha_empresa\n"
                    As You can see there are a lot of \n that theoretically should insert a CR on the line, instead everything is appearing at the email on M.Outlook on the same line. It's very confusing to read.

                    I will keep on making more experiences, but in the meanwhile if there is something that You can immediately see under Your experienced programmer eyes, that could solve this issue, I would very much appreciate all the help.

                    Thanks,
                    pipesportugal

                    Comment


                    • #11
                      Re: php mail function

                      Since your mail is plain text, you should be using :

                      $mail -> IsHTML(false);

                      For the new line issue, it is simple:

                      $mail->Body = nl2br($message);
                      Navaldesign
                      Logger Lite: Low Cost, Customizable, multifeatured Login script
                      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                      Comment


                      • #12
                        Re: php mail function

                        Beatiful naval,

                        Works just as I wanted to.

                        Thanks a lot.
                        pipesportugal

                        Comment

                        Working...
                        X