Linode Forum
https://forum.linode.com/

PHP script to use mail(x) for sending email using bash
https://forum.linode.com/viewtopic.php?f=11&t=7837
Page 1 of 1

Author:  BipBop [ Thu Sep 29, 2011 4:22 pm ]
Post subject:  PHP script to use mail(x) for sending email using bash

Hello :)

On my linode I want to use Google's smtp servers to send some emails. I have the mailx program installed and this works great from bash.
Code:
# echo "This is a test email" | mail -v -s "Test email" someone@somewhere.com


All I need is to be able to provide the body, subject and to address from a PHP script and forward it to bash (anyway to do it inside PHP?) so it can send it away. I just need to send emails.. and can't get sendmail package working.

I am not much of a programmer so any help is very appreciated.. I was thinking of something along the lines.

Code:
<?php
mailfunction ($to, $body, $subject) {
    echo exec('echo $body | mail -v -s $subject $to');
>


Any chance something like that can work? Or if the syntax of the "echo" command inside exec is even correct. Thanks for any help/pointers. :)

Author:  GLaDOSDan [ Thu Sep 29, 2011 4:25 pm ]
Post subject: 

You probably shouldn't use exec like that, but anyway.

First google result:

http://email.about.com/od/emailprogramm ... g_Mail.htm

Author:  BipBop [ Thu Sep 29, 2011 7:20 pm ]
Post subject: 

that google result is more geared towards php running in a windows environment. I know php is the same, but I tried using what they are saying and got nowhere.

Now I am looking at using PHPMailer.. still no luck tho. :(

Edit: Just to clarify I don't have any mail servers (sendmail, postfix, exim etc.) running.. just trying to send mail with php (have pear extension). Is this even doable? :? I have seen a ton of posts on the net regarding this but really nothing has worked for me.

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/