Announcement

Collapse
No announcement yet.

Chaning the from: address when emailing users

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

  • Chaning the from: address when emailing users

    Hi all,

    Pls help! I desperately need to solve this problem!

    I am having problems sending emails to users from the control panel. I think this is a mail server issue with my new host (fasthosts.co.uk). Apparently their system checks the to: and from: address and does not allow it unless one or other of the addresses is hosted with them (to reduce spam I guess). I tried changing the from address in the from: field when sending email but it doesn't work

    I was told by my host's tech support a couple of possible solutions:

    1) By including a -f flag as this makes sendmail use whatever is after it as the from address. Where do I change this?

    2) I could try "hardcoding" the from address in the script like: <?php
    mail($tomail, $subject, $content, "From: [email protected]" );
    ?>

    Am I not changing the from address when I change it in vbulletin options > contact details > webmaster email?

    My mailtest is at: www.soccerpages.com/forum/mailtest.php
    My phpinfo is at: www.soccerpages.com/forum/phpinfo.php

    Many Thanks for your time!

    Kerry

  • #2
    Kerry, didn't you already ask this in another thread? If your host's information is correct, then simply using an email address hosted on their server's should be enough. If you are doing this and it's not working, then their info is not correct and you need to contact them about this.
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography


    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    Comment


    • #3
      Steve,

      I wanted to clarify the problem in a new thread. I've spoken to them again and they said I have to use a -f parameter in the php code for it to work. Can you tell me where I have to edit this please?

      Here's what they sent:

      Next, you need to create the sendmail.php script, using the facilities available in PHP, e.g. <?
      mail( "[email protected]", "Feedback Form Results",
      $message, "From: $email", "[email protected]" );
      header( "Location: http://www.yourdomain.com/thankyou.html" );
      ?>

      When the form is submitted to sendmail.php, the contents of the email field in the form are inserted into a PHP variable called $email, and the contents of the message field are inserted into the variable $message. The script calls a special function called mail, which takes care of the actual dispatch. The first parameter to mail is the address to which you want the form contents sent, in this case your own e-mail address. The second parameter is the subject of the email message, the third is the content of the message, and the fourth is the "From" header so that you know who the sender is, and can reply.

      In order for the script to work, you need to specify, via a fifth -f parameter, the domain from which the mail is being sent. The PHP component uses SMTP (Simple Mail Transfer Protocol), and all Fasthosts' SMTP servers have filters which ensure that the data returned by either the first or fifth mail parameter relates to one of your domains hosted by Fasthosts. The final part of the script thanks the visitor for the message. This is done by sending an HTTP header back to the visitor's browser telling it to load a file called thankyou.html from your domain. The header function allows you to send any HTTP header back to the browser. NOTE: The script has to be enclosed within the <? and ?> tags because the PHP processor treats all input as HTML code unless otherwise specified. On some systems, you may need to use <?php and ?> as the opening and closing tags to get the script to work.

      Comment


      • #4
        Their explanation is very convoluted to say the least. 'If' they are correct then you will need to modify every vB script that sends email. Honestly I've never heard of a host creating so many mail problems as this one does.

        As per their instructions, try this modified mailtest.php (substituting [email protected] with the appropriate info:

        HTML Code:
        <html><head><title>PHP Mail Tester</title></head>
        <body>
        <?php
        
        if ($address=="") {
        
          echo "<form action=\"mailtest.php\" method=get><p>Address to email: <input type=text name=address>
        </p>";
          echo "<p><input type=submit value=\"Send email\"></p>";
        
        } else {
        
          $subject = "Testing mail() function";
          $message = "This is a test email";
        
          mail($address,$subject,$message,"From: \"Mail Test\" <$address>", "[email protected]");
        
          echo "<p>Mail sent. Were any errors shown? If there were, mail is probably not set up correctly.</
        p>";
        
        }
        
        ?>
        </body>
        </html>
        Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
        Change CKEditor Colors to Match Style (for 4.1.4 and above)

        Steve Machol Photography


        Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


        Comment


        • #5
          It gives me a parse error:

          (Parse error: parse error, expecting `','' or `';'' in /home/domains/soccerpages.com/user/htdocs/forum/mailtest.php on line 7:

          http://soccerpages.com/forum/mailtest.php

          Comment


          • #6
            Try this instead:

            HTML Code:
            <html><head><title>PHP Mail Tester</title></head>
            <body>
            <?php
            
            if ($address=="" ) {
            
              echo "<form action="mailtest.php" method=get><p>Address to email: <input type=text name=address>
            </p>";
              echo "<p><input type=submit value="Send email"></p>";
            
            } else {
            
              $subject = "Testing mail() function";
              $message = "This is a test email";
            
              mail($address,$subject,$message,"From: \"Mail Test\" <$address>" "[email protected]" );
            
              echo "<p>Mail sent. Were any errors shown? If there were, mail is probably not set up correctly.</
            p>";
            
            }
            
            ?>
            </body>
            </html>
            If this doesn't work then ask you host how this should look since they are the ones with all the restrictions.
            Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
            Change CKEditor Colors to Match Style (for 4.1.4 and above)

            Steve Machol Photography


            Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


            Comment


            • #7
              Is vB removing the slashes before the quotes, or did you forget them?
              edit: try this (I added some slashes):
              HTML Code:
              <html><head><title>PHP Mail Tester</title></head>
              <body>
              <?php
              
              if ($address=="" ) {
              
                echo "<form action=\\"mailtest.php\\" method=get><p>Address to email: <input type=text name=address>
              </p>";
                echo "<p><input type=submit value=\\"Send email\\"></p>";
              
              } else {
              
                $subject = "Testing mail() function";
                $message = "This is a test email";
              
                mail($address,$subject,$message,"From: \"Mail Test\" <$address>", "[email protected]" );
              
                echo "<p>Mail sent. Were any errors shown? If there were, mail is probably not set up correctly.</
              p>";
              
              }
              
              ?>
              </body>
              </html>
              Last edited by WetWired; Tue 11 Feb '03, 12:48pm.
              http://www.zelaron.com/sigs/rotsig.gif

              Comment


              • #8
                Great! It works! Thanks Smachol and Wired...

                What do I do now, what files and where in the files do I need to edit in vBulletin?
                Last edited by tucklis; Wed 12 Feb '03, 7:37am.

                Comment


                • #9
                  Since this now involves hacking you should probably ask over at vbulletin.org. However just search the PHP files for any instances of this mail command and make the changes.

                  Note you will need to redo this everytime you upgrade. I suggest rethinking your choice of web hosts.
                  Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                  Change CKEditor Colors to Match Style (for 4.1.4 and above)

                  Steve Machol Photography


                  Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                  Comment


                  • #10
                    what would I search for specifically, and what would I replace it with?

                    Comment


                    • #11
                      Search for the string:

                      mail($address

                      And replace that line with the code that works.
                      Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                      Change CKEditor Colors to Match Style (for 4.1.4 and above)

                      Steve Machol Photography


                      Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                      Comment


                      • #12
                        vBulletin 2.2.10 and vBulletin 3.0 will have a centralized location for the mail function so it will be easier to change. You could even move it to an outside file and class if you choose so changes are easier when you upgrade.
                        Translations provided by Google.

                        Wayne Luke
                        The Rabid Badger - a vBulletin Cloud demonstration site.
                        vBulletin 5 API - Full / Mobile
                        Vote for your favorite feature requests and the bugs you want to see fixed.

                        Comment


                        • #13
                          When will I be able to get a copy of 2.2.10 or 3.0? So I'll just have to change one line of code every time I upgrade?
                          Last edited by tucklis; Thu 13 Feb '03, 3:08am.

                          Comment


                          • #14
                            Originally posted by Steve Machol
                            Search for the string:

                            mail($address

                            And replace that line with the code that works.
                            I have searched for this string in all files under /forum/ and /forum/mod and /forum/admin and it only finds the string in mailtest.php (within a search and replace function in dreamweaver)... What can't I find any other instances of this?

                            Comment


                            • #15
                              We hope to release vB2.2.10 (or 2.3.0 if we decide to call it that) later today, so hold on!

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X