muquit / mailsend

A program to send mail via SMTP from command line
Other
298 stars 68 forks source link

MailSend Freezes When Called Within PHP :( #120

Closed amiga-500 closed 7 years ago

amiga-500 commented 7 years ago

Love this thing and have gotten it to work from CLI with ease. However, for the life of me i can't figure out how to get this thing to respond back properly when i launch it within PHP. For example:

From shell if i type the following i get back a response: "Mail sent successfully":

**root@Rooter:~#** mailsend -to test@gmail.com -from "My Name" -starttls -port 587 -smtp smtp.gmail.com -sub "My subject here" -user myemail@gmail.com -auth-plan -pass "mypass" -cs "us-ascii" -enc-type "7bit" -M "My body message here"

Message: My body message here
Mime type: text/plain
Disposition: inline
Encoding type: 7bit

Mail sent successfully

**root@Rooter:~#**

However, within a PHP script if i run the same line using the exec() function like the following, then nothing returns back and the PHP script is frozen (inifinitely waiting for a response to return):

<?php

@exec( 'mailsend -to test@gmail.com 
                 -from "My Name"
                 -starttls -port 587
                 -smtp smtp.gmail.com
                 -sub "My subject here"
                 -user myemail@gmail.com
                 -auth-plan
                 -pass "mypass"
                 -cs "us-ascii"
                 -enc-type "7bit"
                 -M "My body message here',
       $output,
       $retCode
    );

// This area is never reached because the above exec() call never finishes

Ideally, i would like it to return AFTER a message has sent so i can continue my script processing and ideally i would like to get back the results (in the above example i use exec's $output reference variable to see the text results so i can parse to find out if the message was sent successfully)