1

I have configured aws's ses service but have not been able to use it. My emails are being sent but they are sent through my hosting server (Godaddy) and I would want to send them only through AWS's SES. Pardon me, if I have made a rookie mistake.

Here's what my code looks like

<?php require 'PHPMailerAutoload.php'; require 'class.phpmailer.php'; $mail = new PHPMailer; $mail->SMTPDebug = 2; $mail->Host = 'email-smtp.eu-west-1.amazonaws.com'; $mail->Port = 25; $mail->ssl = true; $mail->authentication = true; $mail->Username = 'username'; $mail->Password = 'password'; $mail->setFrom('[email protected]', 'Test Email'); $mail->Body = 'Test Email from Zigsaw'; $mail->AddReplyTo('[email protected]', 'Candidate'); $mail->addAddress('[email protected]', 'Recruiter'); $mail->Subject = 'Test Email from Zigsaw'; if(!$mail->send()) { echo "Email not sent. " , $mail->ErrorInfo , PHP_EOL; } else { echo "Email sent!" , PHP_EOL; } ?> 

Disclaimer: My file is hosted on a godaddy server and I am trying to send emails through AWS SES.

10
  • 1
    Did u get any error? Commented Feb 8, 2018 at 11:51
  • 1
    Don't just make stuff up and expect it to work: $mail->ssl = true; is completely fictional. Base your code on the examples provided with PHPMailer, and use the latest version. Commented Feb 8, 2018 at 11:53
  • @SuneelKumar No Error. Like I said, Email was sent & received. But it was sent through my hosting server and not through SES. I would want to send the emails through ses (Email Server Reputation & Volume) Could you suggest anything? Commented Feb 8, 2018 at 11:53
  • 1
    Yes - change your ISP to one that doesn't block SMTP. Commented Feb 8, 2018 at 12:05
  • 1
    Probably not, unless SES has an HTTP API. GoDaddy is cheap for a reason... Commented Feb 8, 2018 at 15:42

1 Answer 1

1

GoDaddy blocks outbound SMTP, but you've not told PHPMailer to use SMTP (so most of your settings do nothing), so it's submitting via the mail() function, using a local mail server, which in GoDaddy's case is their server - so that's why it's going that way. Unfortunately there isn't a way of using external SMTP on GoDaddy, though you can send via their secureserver.net relay - but that of course means you can't send using your personal domain because it's forgery and you messages will be spam-filtered or bounced.

If you call:

$mail->isSMTP(); 

PHPMailer will use SMTP and your other settings, though as I said in my comment, you've just invented a bunch of things that will not work, so rewrite your code based on the examples provided, though this won't work on GoDaddy.

If SES has an HTTP API, so you may be able to use that instead, since it will not be subject to GoDaddy's blocking.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @Synchro I used the code on my local server and it worked like a charm. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.