How do I get Phpmailer to send from my own server?

Asked

Viewed 333 times

0

I asked the question below and after trying several ways to send email via localhost I got it from Phpmailer:

How to send email from localhost using the PHP mail function?

However I got through the own example for Gmail that is inside the 'examples" folder of Phpmailer.

I wanted to know the following, if I build a small website using Phpmailer when I go to host I will have to upgrade the Phpmailer classes that’s not it?

I know it’s a somewhat obvious question, but my concern is whether I can take advantage of the code set up for Gmail.

Just change the server and stuff?

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';

//Set the SMTP port number - 587 for authenticated TLS, a.k.a.
RFC4409 SMTP   submission $mail->Port = 587;

On these lines I will put the server where I will host my site?

  • You want to continue sending by Gmail from your server, or not?

  • Each server can have its own requirements. But it seems to me that its sample code is using Gmail’s SMTP, not its own server. Could elaborate better?

  • I don’t want to keep sending it through the gmail. This is exactly the question: to send by server I need to change only a line and I would have to redo all the code?

1 answer

1


Yes, yes, you can (and it’s interesting) reuse the code.

You will only need to edit the parts pertaining to setting up the mailing server, as you described in your post.

  • Thanks, I’ll just wait if someone puts something extra.

  • Ah, doing a rereading, I think you got confused: the lines described should be configured to the mail sending server (SMTP). If the server where you host your site has an SMTP server, then you can configure the file according to your server settings.

  • and if it is not SMTP? I change another part?

  • Phpmailer only supports SMTP and POP before SMTP. If you want to use POP before SMTP, you will need to make some changes to your code. I suggest you use example provided by developers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.