How to configure email from a php server using exim4?

Posted on 2007-10-11
Last Modified: 2013-12-18
I currently have a web server running apache/php.  We want to be able to send e-mail through the php command mail().  I was told that you need to install either exim4 or a program similar to that.  I am running Ubuntu so I want to the Synaptic packet manager and I downloaded and installed exim4.  What I have found out so far is that you need to update the php.ini file in order to be able to do this.  I have edited two parts of the php.ini file.
sendmail_path = /usr/sbin/sendmail -t
sendmail_from =
I am not sure if that is right, if anyone knows please tell me?
Next I need to be able to configure Exim4 since I have not done that yet.  Can anyone tell me how to configure exim4 so that it will work?
I think once I get the php.ini file configured properly and then I get the exim4 stuff set up right it should work.  If that is not the case please let me know.  
Question by:sevenpeaks
    LVL 1

    Expert Comment

    LVL 17

    Accepted Solution

    I would use PHPMailer

    it was much easier to use.

    We are using Apache2, PHP on Ubuntu. And Mail was a pain in the neck to get working. PHPmailer, the installer does a lot for the config, and then it just worked.

    Try that out, they have a very good tutorial on how to use it as well.

    Author Comment

    Ok, I  am trying to use the phpmailer program.  I have downloaded it and have placed the class.phpmailer.php into the web directory.  I have edited the php.ini file so that the only line that i have changed is sendmail_path = class.phpmailer.php.  So when I do a test I am getting errors, so I guess that I have not configured it correctly.  Any ideas of what  I am doing wrong?
    LVL 17

    Assisted Solution

    comment out the sendmail_path


    You put the class.phpmailer.php in your web dir.
    in your php file
    require("class.phpmailer.php"); //make sure it's the relative path to the phpmailer file

    $mail = new PHPMailer();

    $mail->Host = "ipaddress of smtp server";
    $mail->SMTPAuth = false; //or True if your smtp server requires authentication.
    ///comment out the following two lines if your smtp server requires authentication.
    //$mail->Username = "username";
    //$mail->Password = "password";
    //end of authentication
    $mail->WordWrap = 50; //or how many characters you want it to be before it wraps. If you do not //provide a value it will go on for a long time.
    $mail->IsHTML(true); //false if you want plain text, but HTML is always better.
    $mail->From = "";
    $mail->FromName = "You Name";
    $mail->AddAddress("", "");
    $mail->AddReplyTo("", ""); //this can be the same has from
    $mail->Subject = "subject";

    $mail->Body = "The body of your email, if html is true then you can place html tags here.";
    if (!$mail->Send())
       echo "Message was not sent <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;

    Author Comment

    Yeah once I added the class.phpmailer.php file and the smtp.phpmailer.php file to the web directory then it worked great.  You don't even have to edit the php.ini file at all.   Thanks for your help. This was a lot easier then exim.
    LVL 17

    Expert Comment

    Thats why I recommend phpmailer all the way.
    I like simple.
    Why did I become a programmer?
    LVL 17

    Expert Comment

    Why "B"?

    did it not solve the problem?

    Author Comment

    I guess I gave you a B becuase you didn't say anything about the class.smtp.php file that needed to be included.
    Also, I didn't have an installer when I downloaded it.  I had to figure out that it didn't need to be installed, that it was just two files that need to be added to the web directory.  
    LVL 17

    Expert Comment

    the class.smtp.php file is not to be touched.

    just by using $mail->IsSMTP();
    it uses that file. Go through line by line of the class.phpmailer.php if you don't believe me.

    Author Comment

    I know it doesn't have to be touched, but I didn't even know that I had to move it to the directory.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Integrate social media with email signatures

    Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

    MS outlook is a premier email client that enable you to send and receive the e-mails with various file formats of attachments such as document files, media file, and many others formats. There is some scenario occurs when a receiver of an e-mail mes…
    Import PST to Exchange using Power Shell new-mailboximportrequest command, you can simply import the PST file into Exchange mailbox or archived. To know How to import PST into Exchange  2013 read the complete article.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now