0

I've worked on this for hours. Seriously very frustrated. I don't know code at all and in serious need of help.

I am trying to get an email automatically sent as users reach a particular point in a website. But everything I've tried says error 500. so I am currently following numerous tutorials that suggest downloading this https://github.com/PHPMailer/PHPMailer. Which I've done, including uploading it to my host and nothing occurs.

Please if anyone can help, I seriously don't know code at all so examples only, please.

<?php
    require_once ('../PHPMailer/PHPMailerAutoload.php');

    $mail= new PHPMailer();
    $mail->isSTMP();
    $mail-> SMTPAuth = true;
    $mail->SMTPSecure='ssl';
    $mail->Host='smtp.gmail.com';
    $mail->Port='465';
    $mail->isHTML();
    $mail->SetFrom('no-reply@eves.website')
    $mail->Subject='Hello World';
    $mail->Body='A test email!';
    $mail->AddAddress('brodisashcroft@gmail.com');

    $mail-> Send ();

?>
Patrick Moore
  • 13,251
  • 5
  • 38
  • 63
B.Ashcroft
  • 75
  • 7
  • Can you post the full error message you are getting? – drum Apr 09 '18 at 03:06
  • @drum "This page isn’t working www.eves.website is currently unable to handle this request. HTTP ERROR 500" – B.Ashcroft Apr 09 '18 at 03:07
  • Does PHPMailer actually exist one directory up from where this file is located? If not, your very first line `require_once()` is failing to include the PHPMailerAutoload file. – Patrick Moore Apr 09 '18 at 03:07
  • It's not a good idea to publish valid email addresses, since spammers could use them to send junk mail. Now, as @drum suggested, please post the error message, if it's not displayed in the web page, you need to search the exact text in the error log. – Triby Apr 09 '18 at 03:08
  • Which version did you download? Why are you not using composer? – Lawrence Cherone Apr 09 '18 at 03:08
  • I've tried both the master and the 5.2 @LawrenceCherone – B.Ashcroft Apr 09 '18 at 03:09
  • @Triby this is exclusively for a one time assignment, these emails will never be used again, except for the presentation of the website to my lecture – B.Ashcroft Apr 09 '18 at 03:10
  • Your need https://github.com/PHPMailer/PHPMailer/tree/v5.2.26 or your open yourself to like 15 vulnerabilities .. but you should use composer and use the latest version. – Lawrence Cherone Apr 09 '18 at 03:12
  • @LawrenceCherone I don't know what a composer is, very new to this – B.Ashcroft Apr 09 '18 at 03:16
  • @PatrickMoore Yes it is one directory up – B.Ashcroft Apr 09 '18 at 03:26
  • Your not trying to send a smtp mail to yourself from yourself are you? Because that doesn't work in gmail over smtp. Or at least it didn't when I set up my SMTP mail, (like 4 years ago) – ArtisticPhoenix Apr 09 '18 at 03:33
  • @ArtisticPhoenix no two separate emails – B.Ashcroft Apr 09 '18 at 03:34
  • Ok, because I tried for like 5 hours then i sent it to another account by accident and behold it worked. lol, but as I said that was 4 years ago, also I only use it on local host because I'm to lazy to setup a test email server ... lol – ArtisticPhoenix Apr 09 '18 at 03:36
  • @ArtisticPhoenix If only that was the case here, I did set up a test email and still nothing – B.Ashcroft Apr 09 '18 at 03:40
  • Email is a fickle thing, did you check your spam folder? – ArtisticPhoenix Apr 09 '18 at 04:04
  • Have you set username and password? Coz I don't see that in your script: https://stackoverflow.com/questions/18535294/mail-not-sending-with-phpmailer-over-ssl-using-smtp – Michael Eugene Yuen Apr 09 '18 at 06:14
  • Also, according to your error, please check your dns settings for eves.website coz it has an MX error: https://intodns.com/eves.website – Michael Eugene Yuen Apr 09 '18 at 06:21

1 Answers1

1

You're missing a semicolon here:

$mail->SetFrom('no-reply@eves.website')

At the end of the line:

$mail->SetFrom('no-reply@eves.website');
Patrick Moore
  • 13,251
  • 5
  • 38
  • 63