SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 37
  1. #1
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)

    Help Setting up SendMail on Fedora 17

    Edit:

    This is a continuation from http://www.sitepoint.com/forums/show...86#post5345386, the issue the OP now has is setting up SendMail on his local Linux server which is running Fedora 17. I'm not all that familiar with Fedora, so if you have expertise, please lend a hand if you are able.


    Okay, you can remove the echo and die statements now, the process of inserting and updating is working as expected

    Now on to e-mail.
    1) Are you running PHP on a local server? ie: Your PC, or on a remote server?
    2) Is it a Windows Server or Linux Server?
    2a) If Windows, are you using Apache or IIS?
    3) Do you know your SMTP information for your school's email server?
    3a) Do you know the SMTP server name/address? usually smtp.mydomain.com
    3b) Do you know if a username and password are required for sending e-mail through the smtp server?
    3b1) If Yes, do you know what the username and password are?

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay, and what about the

    //After teacher has entered marks...........
    $message =<<<EMAIL_MESSAGE
    'Dear Student, for your information, scores for your most recent examination have been uploaded. Please visit Med Buddy to view your score. Thank you.
    EMAIL_MESSAGE;


    should it stay there/?

    well,
    1.i m running it on my localhost
    2.linux server
    3. nope, i don't know the SMTP information for the schools email server... ....

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Yes, that top part is called HEREDOC, it allows you to build a string of output much easier than using string concatenation (Granted that first ' shouldn't be there).

    Okay, so you are running on linux, which means you need to setup sendmail on your linux machine. What distro are you using?

  4. #4
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    distro??sorry, what's that?

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Debian, Ubuntu, Fedora, CentOS, etc. Which distribution of linux are you using?

  6. #6
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh, fedora i guess...

  7. #7
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jay93 View Post
    oh, fedora i guess...
    You guess? , best answer I've had from someone who is running a local linux server

    Try running "uname -r" from the command line/terminal/konsole (whatever you may have on your setup)

  8. #8
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol... i got this, 3.6.2-4.fc17.i686

  9. #9
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, definitely fedora version 17.

    First I'd start with:
    http://richardwillia.ms/blog/2011/09...mail-in-fedora

    If that doesn't work, may have to install PHPMailer and use that instead of mail()

  10. #10
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how do i test if it worked?? and do i enter those commands

    $ setsebool -P httpd_can_sendmail 1
    $ /etc/init.d/httpd restart

    in my terminal???

  11. #11
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it says command not found

  12. #12
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    okay, that is good and bad, that tells me you don't have SELinux setup, which means I don't have to worry about additional security trying to figure out how to get this setup on Fedora

    On a side note, I'm going to split this tread again, and move this SendMail configuration process to the Server Configuration forum (where it will hopefully get more help).

  13. #13
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, you got me there... i was wondering instead of configuring stuff, isnt there a way we could send mail through some free smtp, or gmail (my gmail account)??

  14. #14
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You can try using PHPMailer

    First run
    Code:
    yum install php-PHPMailer
    Then check out the examples on this page:
    http://stackoverflow.com/questions/1...mail-on-fedora

  15. #15
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wait, so do i like copy all of this

    require_once('../class.phpmailer.php'); ///WHERE IS THE LOCATION FO THIS FILE?
    $mail = new PHPMailer(true);

    $mail->IsSMTP(); ////////////////////////SHOULD I LEAVE IT LIKE THIS??

    try {
    $mail->SMTPAuth = true; // enable SMTP authentication
    $mail->SMTPSecure = "tls"; // sets the prefix to the servier
    $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
    $mail->Port = 587; // set the SMTP port for the GMAIL server
    $mail->Username = "yourusername@gmail.com"; // GMAIL username
    $mail->Password = "yourpassword"; // GMAIL password

    //This is the "Mail From:" field
    $mail->SetFrom('name@yourdomain.com', 'First Last');
    //This is the "Mail To:" field
    $mail->AddAddress('whoto@otherdomain.com', 'John Doe');
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
    $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";

    $mail->Send();
    echo "Message Sent OK<p></p>\n";
    } catch (phpmailerException $e) {
    echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
    echo $e->getMessage(); //Boring error messages from anything else!
    }



    into where i currently have mail($studentEmailAddress, 'New Scores Uploaded!', $message);????

  16. #16
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Yes, and no.

    First, I'd put all of that into a separate file for testing purposes, then we'll eventually extract it into a more reusable format once it is working.

    If you ran the yum statement, I believe you can just put require_once('class.phpmailer.php'); but you may need to restart the httpd service.

    If that doesn't work, you can download it from http://code.google.com/a/apache-extr...4.zip&can=2&q=

    Extract the download into your php script folder hiearchy, and include it in your class.phpmailer.php file

    Leave the IsSMTP (especially if you plan to use gmail to send your communication).
    Update the appropriate auth variables.
    Run the script.
    Once it sends you an e-mail, let me know and I'll help you extract it to hide a lot of the common components so you can have a one line call to replace mail() with.

  17. #17

  18. #18
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    works perfectly now... emails are going...

  19. #19
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Great.

    Okay, so now to refactor it.

    PHP Code:
    function send_email($to$subject$message)
    {
      
    // Paste PHP Mailer code, change
      // $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); to $mail->AddAddress($to);
      // $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; to $mail->Subject = $subject;
      // $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; to $mail->Body = $message;

    Then where you have mail(), you can replace the word mail with send_email

  20. #20
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k,,, but there was one little thing i thought would be nice if we do it,

    in this part of the php mailer code,

    $mail->Subject = 'New Scores Uploaded'; i wished to replace "New Scores" with $_POST["subject"]... but it gave me some ugly error about """ apostrophes and stuff, what is the right way to go about th is??

  21. #21
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    So me the code you have and I'll help you out

  22. #22
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this part here...

    //This is the "Mail From:" field
    $mail->SetFrom('admin@medbuddy.com', 'Exam Coordinator');
    //This is the "Mail To:" field
    $mail->AddAddress("$studentEmailAddress", ' ');
    $mail->Subject = 'New Scores Uploaded'; //<-----------------------THIS ONE

    could we replace this with the name of the subject the teacher selected in the dropdown menu, as in $_POST["subject"]???i tried doing that but it gave me some syntax error...

  23. #23
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $mail->Subject $_POST['subject'].' Uploaded'
    Or if you refactor it
    PHP Code:
    send_mail($studentEmailAddress$_POST['subject'].' Uploaded!'$message); 

  24. #24
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, that too worked... i'm almost getting there now, just a few more hurdles...this one is a bit about design, with my headers templates...is there a way i could make the one on the login.php page different from that on the teachers form page and students page??

    for eg. this is what i have at the moment for two pages, login.php (my homepage) and teachers.php

    CAP.JPG

    CAP2.JPG

  25. #25
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and btw, the texts on the website the #1 blah blah are temporary... lol


Bookmarks

Posting Permissions

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