Results 1 to 12 of 12

Thread: php mail function
      
   

  1. #1
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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 at 06:16 AM. Reason: posted control panel user name

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default 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!


  3. #3
    dwill525 is offline Private
    Join Date
    Oct 2008
    Posts
    3

    Default 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);

  4. #4
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default 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!


  5. #5
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default 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!


  7. #7
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  8. #8
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  9. #9
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: php mail function

    Quote 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!


  10. #10
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  11. #11
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default 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!


  12. #12
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default Re: php mail function

    Beatiful naval,

    Works just as I wanted to.

    Thanks a lot.
    pipesportugal

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49