php - Sending mail with gmail SMTP (Fixing someone's code) -
this may long, i'm sorry.
recently decided going try , fix code used computer lab send e-mails. used work until tried change sending e-mail address. problem? know little type of coding , pieces of code changed. found function use send mail. hoping point me out problem. or can change make work. i'm thinking it's because password never asked for. don't understand person wrote code doing exactly.
here's code i'm looking at.
function sendmail($toname, $toemail, $fromname, $fromemail, $subject, $body, $header) { $smtp = fsockopen("smtp.gmail.com", 465); $inputbuffer = fgets($smtp, 1024); fputs($smtp, "helo $smtp.gmail.com\n"); $inputbuffer = fgets($smtp, 1024); fputs($smtp, "mail from: $fromemail\n"); $inputbuffer = fgets($smtp, 1024); fputs($smtp, "rcpt to: $toemail\n"); $inputbuffer = fgets($smtp, 1024); fputs($smtp, "data\n"); $inputbuffer = fgets($smtp, 1024); fputs($smtp, "$header"); fputs($smtp, "from: $fromname <$fromemail>\n"); fputs($smtp, "to: $toname <$toemail>\n"); fputs($smtp, "subject: $subject\n\n"); fputs($smtp, "$body\r\n.\r\n"); fputs($smtp, "quit\n"); $inputbuffer = fgets($smtp, 1024); fclose($smtp); }
they press button , sends email. or runs function @ least. found when press button variables called. other variables called database stores personal info. (changed email random 1 post question.)
$fname = mysql_result($results, 0, "fname"); $fromname = "support center"; $fromemail = "jonstevens93@hotmail.com"; $subject = "computer finished"; $body = "your computer fixed."; $header = "computer";
would able possibly point me in right direction. or can please explain how make program output error message? i've googled around , found topics talking i'm still lost. better write new code , not try fix since i'm novice? appreciated i'm slight novice @ type of code. can read , understand it, but... don't understand in depth functions.
it might easier rewrite sendmail function contents , use phpmailer class instead of manual socket interaction. can send emails in different ways - mail() function, sendmail or smtp. easy configure , throw exceptions when wrong during smtp sessions. place somewhere in site , @ examples provided package.
Comments
Post a Comment