How to send mail from (a) a C program and from (b) PHP? - Mandriva

This is a discussion on How to send mail from (a) a C program and from (b) PHP? - Mandriva ; I have a stock Mandriva 2007 (client) installation and I use KMail for my email. If I want to send an email programmatically (e.g. from a C program), what should I look at (install)? I am also toying with PHP ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: How to send mail from (a) a C program and from (b) PHP?

  1. How to send mail from (a) a C program and from (b) PHP?

    I have a stock Mandriva 2007 (client) installation and I use KMail for
    my email.

    If I want to send an email programmatically (e.g. from a C program),
    what should I look at (install)?

    I am also toying with PHP and it's mail() command. It's not working.
    I installed sendmail, but that hasn't helped (yet).

    Is sendmail what I want to get PHP's mail() command to work or is
    something else recommended? If not sendmail, what do I stick in the
    php.ini file for sendmail_path?

    (BTW, I connect to my ISP via a Linksys BEWF11S4, if that might have
    something to do with my lack of success thus far).

    Hints and pointers appreciated.

    thanx
    pt


  2. Re: How to send mail from (a) a C program and from (b) PHP?

    On 5 Apr 2007 13:29:52 -0700, tarvydas@allstream.net wrote:

    > If I want to send an email programmatically (e.g. from a C program),
    > what should I look at (install)?


    I would first try sending the mail from the command line to see if it works.
    Example:
    /bin/mail -s "sub text here" $USER@$(hostname) < /ascii/file_fn.here
    mail <==== look in your mail box
    1 <==== read message
    d <==== delete mail msg
    q <==== quit mail

    Once that works you can use one of the exe* functions to do the same
    thing using a real email address.


    > I am also toying with PHP and it's mail() command. It's not working.
    > I installed sendmail, but that hasn't helped (yet).


    Well I would unistall sendmail and install postfix if not already installed.
    Documentation would be in someting like
    /usr/share/doc/postfix-2.3.3/html/index.html


    Do modify /etc/postfix/aliases. You need to
    change root: postfix
    to root: tarvydas

    then
    postalias aliases
    to create the aliases database file.


    You then add some commands to bottom of /etc/postfix/main.cf to
    help your MTA (postfix) to manage mail routing and whatnot.
    If you want your ISP MTA to route mail not destined to a LAN account
    you have to set relayhost
    mynetworks is my LAN ip address range

    Here is what I did to mine


    # my appended changes to main.cf for my WAN node

    default_destination_concurrency_limit = 1

    masquerade_exceptions = root
    mydestination = $myhostname localhost.$mydomain localhost $mydomain
    mynetworks = 192.168.2.0/24, 127.0.0.0/8
    relayhost = [smtp-server.tx.rr.com]
    relay_domains =
    inet_interfaces = all
    unknown_local_recipient_reject_code = 550
    smtp_host_lookup = dns, native


    # local box users, and to generate database file
    # postmap virtual
    virtual_alias_maps = hash:/etc/postfix/virtual


    # Sending: swap out email addresses that appear inside messages (From
    # added a line like
    # bittwister@wb.home.invalid my_addy@yahoo.com
    # postmap generic

    smtp_generic_maps = hash:/etc/postfix/generic


    #****** end main.cf ****************

  3. Re: How to send mail from (a) a C program and from (b) PHP?

    On 5 Apr 2007 13:29:52 -0700, tarvydas@allstream.net wrote:

    > I installed sendmail, but that hasn't helped (yet).


    I do hope you have enabled the firewall to prevent anyone from
    connecting to your MTA.

+ Reply to Thread